enormous input test (time limit)

my submission to this problem is:
http://www.codechef.com/viewsolution/1568490
and it has an execution time of 5.57

and this submission:
http://www.codechef.com/viewsolution/1566921
has an execution time of 0.67

i have got a little idea about this code… but i am not clear …can someone please explain this program to me ?? and that fread … isn’t that for reading a file??

Hello maximus2x,

First of all, you have the same link repeated, such that you seem to mention to different solutions that are actually the same one from the point of view from who reads the question!!!

Secondly, yes, fread is tailored to read files… But, it can be “overloaded” to read from the stdin if you specify it on the (FILE * stream) parameter… So you can actually perform relatively faster I/O operations if you take advantage of this…

Refer to http://cboard.cprogramming.com/c-programming/113702-using-fread-read-stdin.html for several issues and examples of such usage.

Best regards,
Bruno

1 Like

thanks bruno, i have edited my post… now both links are different…thanks for your reply… and you got my doubt … check out the 2nd link and let me know if you can tell something else about that code…