pwn's blog

By pwn, 12 years ago, In English

Please have a look at these two solutions, the code using cout is accepted but the code using printf is giving TLE. I always thought printf is faster than than cout. What do you think?

http://codeforces.me/contest/436/submission/6890501

http://codeforces.me/contest/436/submission/6890486

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
12 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I don't know for sure but maybe you have TLE on the first submission because of combining cin and printf? Try to use stdio only

»
12 years ago, hide # |
← Rev. 7  
Vote: I like it 0 Vote: I do not like it

Firstly, your solution is really slow.

Secondly http://codeforces.me/contest/436/submission/6890816 scanf is faster than cin, but i guess printf is slower when it comes to long long int.

Anyway if you have right solution it doesn't matter if u're using cout or printf :)

EDIT: Check this ( I've changed your solution so i can use int everywhere )

http://codeforces.me/contest/436/submission/6890858

http://codeforces.me/contest/436/submission/6890844

»
12 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

See if this helps in any way.