DIVPAIR: Same code giving tle and wa in two submissions

, ,

Refer these two submissions http://www.codechef.com/viewsolution/1042351 and http://www.codechef.com/viewsolution/1042344. One is using stdio.h and the other iostream. Both do exactly the same job-print “0”. However, one gives TLE whereas the other gives the expected response-Wrong Answer. How is this possible? During the contest I coded my solution using iostream and got a TLE. Now I see that my solution was exactly the same as that of the tester’s but he has used stdio. Is the difference in input/output streams giving me a TLE?

1 Like

Refer to FAQ. It is stated that

The second most common cause of TLE is that your method of reading input and writing output is too slow. In Java, do not use a Scanner; use a BufferedReader instead. In C++, do not use cin/cout - use scanf and printf instead.


When one code is using stdio.h and another iostream,it’s not the same code, please change the title.

‘Same Code’ here refers to the same logic/method etc.