CandidateNextYear's blog

By CandidateNextYear, history, 3 months ago, In English,

Hi everyone
I've just wrote this code 72243144 that has the complexity of O(n.log(n)) which is the same run time of the tutorial solution but I'm stuck with TLE! any help about what's going on? thanks in advance

 
 
 
 
  • Vote: I like it
  • -15
  • Vote: I do not like it

»
3 months ago, # |
  Vote: I like it +8 Vote: I do not like it

endl is very slow as it requires to flush the output. Try replacing endl by '\n'. If you have the good complexity this should work.

»
3 months ago, # |
  Vote: I like it -8 Vote: I do not like it

Cin Cout streams are slower than scanf and printf unless optimized. Use Scanf printf or add this to your code.

ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);

Also endl flushes the output which is slow so replace all endl in your code with '\n'.

»
2 months ago, # |
Rev. 3   Vote: I like it -22 Vote: I do not like it

[Wrong]

  • »
    »
    2 months ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    simple operations of std::pair are always $$$O(\log n)$$$

    ????????

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    sir Pls Explain this I was not under that impression Sir