notAboAlmanalAnyMore's blog

By notAboAlmanalAnyMore, history, 5 years 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

| Write comment?
»
5 years 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.

»
5 years 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'.

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

[Wrong]

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

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

    ????????