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

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

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

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

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

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.

»
4 года назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

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'.

»
4 года назад, # |
Rev. 3   Проголосовать: нравится -22 Проголосовать: не нравится

[Wrong]