http://poj.org/problem?id=2385

need help in this problem.I am able to solve the problem by heap.But Unable by Dynamic Programming

# | User | Rating |
---|---|---|

1 | tourist | 3496 |

2 | Um_nik | 3337 |

3 | Petr | 3298 |

4 | W4yneb0t | 3218 |

5 | Radewoosh | 3216 |

6 | OO0OOO00O0OOO0O0…O | 3188 |

7 | Syloviaely | 3168 |

8 | izrak | 3109 |

9 | anta | 3106 |

10 | fateice | 3099 |

# | User | Contrib. |
---|---|---|

1 | tourist | 185 |

2 | rng_58 | 170 |

3 | csacademy | 165 |

4 | Petr | 158 |

5 | Swistakk | 153 |

6 | lewin | 148 |

7 | Errichto | 147 |

8 | matthew99 | 145 |

9 | Zlobober | 141 |

9 | adamant | 141 |

http://poj.org/problem?id=2385

need help in this problem.I am able to solve the problem by heap.But Unable by Dynamic Programming

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/18/2018 08:04:15 (d2).

Desktop version, switch to mobile version.

User lists

Name |
---|

You know, some Chinese symbols and "Peking University" doesn't quite indicate it is Polish Online Judge :p

can you tell the answer?

dp[i][j][k] = the maximum number of apples she could eat in the first i minutes, if the she's standing right now under the tree k and so far she has moved j times. You can easily build the dp in a forward manner by going from state (i, j, k) to state (i + 1, j + (k != p), p) with value dp[i][j][k] +(place_where_the_apple_falls[i] == k) where p is the place she'll be at in the (i+1)th minute. k and p only take values 1 and 2, j is up to W (about 30) and i up to N.

How did you solve it with a heap?