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

Автор toss, история, 10 лет назад, По-английски

Here is my submission:

http://codeforces.me/contest/670/submission/17734251

I get a RUNTIME_ERROR for the 13th test case and I have no idea why. I cannot debug it, since the input is truncated. I tried to reproduce a test case with similar n and k, but random id's and it is working fine, or at least it doesn't cause a runtime error.

I hope that such questions are appropriate for the blog and I would very much appreciate your help. I would also be very happy if you could give me some general tips on how to approach such problems (figuring out why a truncated input caused a runtime error).

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

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

Are you sure, that index is between 0 and n-1?

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

Could it be because of overflows? I googled and found here that long has the same maximum value as int.

You used condition n(n + 1) < 2k in your solution where n is only a "long", which might cause an overflow when k is something like 2e9 where n(n + 1) can be up to almost 4e9.