Hello!
Can anyone explain why my submission: 77862595 to the problem: 1340B - Nastya and Scoreboard is giving a RUNTIME_ERROR with exit code 2147483647 ? It works correctly on my macOS's Zsh terminal.
I tried to get a better understanding using a few online compilers:
cpp.sh Exit code: 0 (normal program termination)
onlinegdb.com *** Error in `./a.out': double free or corruption (out): 0x00000000024daec0 *** ( Note: the address is different every time)
repl.it double free or corruption (out) exited, aborted
What a pity! I don’t know why neither. I think you should check your code again.
In main, one of your loops has a condition of
while(k>0 && i>=0)
, but then inside the loop you havei--
;. This causes i to be -1 and then when it is used as an index, that causes undefined behavior.