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 | 3434 |

2 | OO0OOO00O0OOO0O0…O | 3419 |

3 | Um_nik | 3309 |

4 | fateice | 3306 |

5 | Syloviaely | 3274 |

6 | Petr | 3220 |

7 | dotorya | 3145 |

8 | Radewoosh | 3101 |

9 | mnbvmar | 3096 |

10 | anta | 3053 |

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

1 | tourist | 178 |

2 | rng_58 | 164 |

3 | csacademy | 155 |

3 | Petr | 155 |

5 | Swistakk | 149 |

5 | lewin | 149 |

7 | Um_nik | 143 |

8 | Errichto | 139 |

9 | Vovuh | 138 |

9 | matthew99 | 138 |

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: Jun/25/2018 20:34:36 (d1).

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?