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

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

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

Теги #dp
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

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

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