rahul_1234's blog

By rahul_1234, history, 8 years ago, In English

In today's kickstart problem, https://codejam.withgoogle.com/codejam/contest/6304486/dashboard#s=p1

I am getting wrong answer on big input but smaller input works fine and gives correct answer. Here is my code: https://ideone.com/7Ffer4

I tried with bigger input and answer is coming mostly as 0.

I can't find the error. Can someone tell the error and how to correct it.

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

| Write comment?
»
8 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I think it will lead to overflow in dp array.

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

    No I checked with

    N = 2000

    M = 1999

    There was no overflow in dp though answer was very large in 10^18.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      there is overflow.If u are not convinced try running a loop over the dp array and check if anything is less than zero for testcase N=2000,M=1999


      Answer to the question