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

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

Hi everyone.

I was trying to solve small input for this problem using recursive dp.

But it gives a strange runtime error when n >= 180000.

this my code

Any helps.

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

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think u have issues with stack size.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

You can also iterate backwards through the dp states before answering. If your dp recurrence goes "forward" ( dp(x) depends on dp values greater than x) fill the values from MAXN to 0. Doing that the program will never reach a recursion depth greater than 1. It is a cheap and fast way to fix this kind of issue.