Блог пользователя pwn

Автор pwn, 12 лет назад, По-английски

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

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, скрыть # |
← Rev. 7  
Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

See if this helps in any way.