Hey guys, can someone please help me figure out why I am getting TLE in Challenge problem from this long?


I really dont know what can be the problem, and I did try using all sorts of “flush” and what not :confused: . Any help is appreciated, thanks :slight_smile:

1 Like

Your solutions has a bug.

Where you loop for (int k = 0; k< d; k++){}, now, inner loop should run only upto a+b, not n.

1 Like

Yeah, because I have to only print a pairs once and then take input of b pairs. We run it d times, making it d*(a+b)=N - all robots destroyed. What did I miss?

Can you explain use of i variable in your code. Isn’t it getting re-initialized every time.

It’s a pointer in taran array, or loop index?

The logic is -

1. Initialize i=0;
2. Loop till N until we print A valid pairs
3. Re-initialize it to 0.
4. Take b pairs as input and update frequency.

your loop in which you print a pairs, in case taran[i]>0, do not increment i.

1 Like