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

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

After using Binary search in Problem C(Round 1574) I am getting TLE I don't know where it is getting out of bounds, please help

code link- https://mirror.codeforces.com/contest/1574/submission/181236065

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

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

Your code seems fine speed-wise (it might give Wrong Answer), it's probably slow I/O.

You can add this at the beginning of your code for faster IO.

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ...

}

Just be careful that if you use this, you should stick with cin/cout and not mix it with scanf/print/puts since they use different buffers and the order read/written will be all mixed as well.

»
3 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Use C++20 instead of C++14 and Fast I/O