terminatorCM's blog

By terminatorCM, history, 10 months ago, In English

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

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

»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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);

»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

same thing happened to me