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

Автор terminatorCM, история, 9 месяцев назад, По-английски

In submission 329853944 I got TLE for an answer that has O(2*1e5) can someone help??

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

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

ios_base::sync_with_stdio(0); cin.tie(0); for not adding this I think

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

Even though the algorithm runs in O(n) time, it may still exceed the time limit if there's a large volume of input or output. In such cases, the program's runtime isn't due to computation but rather the slowness of standard input/output operations (cin/cout). To avoid this, we use fast I/O techniques to reduce the overhead of reading and writing data, ensuring that time is spent on actual computation rather than I/O.

Just add this in your solve function : cin.tie(nullptr)->sync_with_stdio(false);

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

same thing happened to me