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

Автор BrainNotFound, история, 2 года назад, По-английски

TLE code : https://codeforces.com/contest/1613/submission/137709567

Accepted code : https://codeforces.com/contest/1613/submission/137711275

The only difference is:

AC : fin(i,0,n){ cout<<v[i]<<"\n"; }

TLE : fin(i,0,n){ cout<<v[i]<<endl; }

I know endl is supposed to be a bit slower because it flushes the output, but how is the difference significant enough to give a TLE?

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

»
2 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

The difference is significant in problems where you have to output multiple lines. The small differences add up.

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

\endl is much slower than \n because of the flushing of the output buffer. In general, just use \n to be safe.