Why it is giving tle?

for every test case it is of O(n)
still it is giving TLE…

hello @we_kaash
u should read next element only if a is non zero.

otherwise ur program will keep waiting for input and it will result in tle.
check this for clarity->

sir why you,ve used cout<<"\n"; there in 61th line?

and a seperate question

if you have to go to next line then why didnt you used cout<<endl; ?

to print output of each test case in seprate line

you can use that as well both will bring u to next line.

\n is preffered over endl becuase endl flushes the buffer because of which it makes ur program little bit slow

but sir as in the sample output there is no demand to print the output in nextline but still your code got submitted :sweat_smile: :sweat_smile:

and

sorry sir, i dont get what actually flushes a buffer means??
i googled it before and same statement was given so i asked here

in sample output there is only single test case so obviously it will not matter (for this case only ) whether u print \n or not.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.