Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

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

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

Good morning/afternoon/evening/night dear codeforces community!

I have been learning Go language to start developing in Back-end, so I decided to practice it by solving simple problems from codeforces. However, I am facing a problem in this problem. Initially I implemented sorting by my own comparator to sort the paired(implemented via struct) array. However I got TLE. After that, I implemented merge sort by my own, and even after this I got TLE again. I thought that problem was in binary seacrh(maybe I write something wrong), so I replaced it with two-pointers method. Unfortunately I got TLE again. Can you tell me, is it possible to get "Accepted" in this problem using Golang?

The final version of code is right here -> https://codeforces.me/problemset/submission/580/226466440

Thanks for your consideration.

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

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

As in many languages the easiest way to do IO isn't the fastest.

226471399 is your first version with the input done using bufio.scanner (140ms). There are further optimizations possible involving scanner.Bytes() instead of scanner.Text().

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

Actually it's recommended to use C/C++ to do competitive programming, for other languages are not made for pure efficiency. In my opinion, in your situation it's not a very good idea to practice simple problems on CF. Use a training site instead. However, if you really want to stick to CF, use a macro template so you don't have to do those tricky optimization every time.