Achha...ji's blog

By Achha...ji, history, 3 years ago, In English

I am stuck around it and unable to figure out the problem ....If anyone who faced this issue or knows the solution for it ..reply in the comments,it will be really helpful. The problem is from Codeforces Educational round 95 div2 .....Here's the Problem and this is my solution implemented using Dynamic programming.

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

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

At the end of each test case, clear out the global dp array. This might solve your issue. :)

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Add condition when ind becomes greater than n

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

    What should it be..?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      0

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

        Thanks man that worked :) ...got AC but not pretty much clear why function should return zero for ind > n

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          Since you are starting your traversal from 1st index so on reaching the last index it means that all the previous bosses have been killed. Now since there is no boss after n, you don't need to kill anyone, hence 0.