architsangal's blog

By architsangal, history, 10 months ago, In English

Just wanted to get some clarification, for the problem D of today's contest (Codeforces Round 891 (Div. 3)). I got this weird error (runtime error) in the following submissions (using java):

When I submitted equivalent code using long, it worked (using java): - https://mirror.codeforces.com/contest/1857/submission/217686813

Using int, cpp code worked though: - https://mirror.codeforces.com/contest/1857/submission/217741962

Anyone has any idea what might have happened? I would really appreciate the help. Thanks in advance.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Found the problem:

(A[i] — B[i]) can be 2* (10^9).

Now when I am using the comparator function on the new array of pairs, it might become: 2* (2* (10^9)). Due to which, there may be an overflow.

Credits: https://mirror.codeforces.com/blog/entry/118765?#comment-1056280