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

Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

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

1 | tourist | 3469 |

2 | Radewoosh | 3357 |

3 | OO0OOO00O0OOO0O0…O | 3264 |

4 | LHiC | 3227 |

5 | ksun48 | 3184 |

6 | scott_wu | 3168 |

7 | Um_nik | 3166 |

8 | CongLingDanPaiSh…5 | 3157 |

9 | Petr | 3139 |

10 | V--o_o--V | 3135 |

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

1 | Radewoosh | 195 |

2 | Errichto | 175 |

3 | rng_58 | 158 |

4 | Ashishgup | 157 |

4 | neal | 157 |

6 | tourist | 154 |

7 | PikMike | 152 |

8 | Petr | 151 |

9 | Um_nik | 149 |

10 | kostka | 148 |

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: Dec/17/2018 23:35:47 (d3).

Desktop version, switch to mobile version.

Supported by

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?