Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

ekdoteen123's blog

By ekdoteen123, history, 8 months ago, In English,

https://codeforces.com/contest/431/problem/C

The recursive solution works but gives TLE for some inputs.

But when I memoize the solution it doesn't give the same results.

Here is my code: https://pastebin.com/EAX7T9RK

Thanks

Tags #dp
 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
8 months ago, # |
  Vote: I like it +1 Vote: I do not like it

You should initialize the dp array with -1's in order to get correct results.

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

    even after doing that, I didn't get the desired results.