naivedyam's blog

By naivedyam, history, 3 weeks ago, In English

I was recently trying out a CSES problem Coin Combinations 2 and THIS CODE GAVE ME MULTIPLE RUNTIME ERRORS while THIS ONE PASSED. If you look closely, both are exact same codes except that the one with runtime errors uses long long instead of int. Why using long long is giving runtime errors here?

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

Instead of making blog like this you can just ask GPT.

»
3 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

I will be your chat gpt for today. Note that you are declaring 10^6 * 100 ints in your AC solution, which is around 400MB. The memory limit is 512MB, meaning 10^8 long longs will MLE (800mb > 512mb), so I'm assuming your RTE is a disguised MLE.

  • »
    »
    3 weeks ago, # ^ |
    Rev. 2   Vote: I like it +4 Vote: I do not like it

    Thanks! I did try gpt though to debug my code (the one which got runtime errors) but it just said wierd stuff that it happens because I am not initializing dp[n][0] (which I never access) and things like that which weren't wrong in my code and even after multiple follow up messages explaining to it why that particular thing is right it would just go back giving the same answers again, even after copy pasting the problem statement in some messages. I had to try changing certain stuff myself and figured out commenting out define int long long works. Chat gpt made me waste about an hour on this.