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

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

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?

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

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

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

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

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 недели назад, # ^ |
    Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

    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.