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 | 3671 |
2 | jiangly | 3653 |
3 | Um_nik | 3629 |
4 | Benq | 3513 |
5 | ksun48 | 3486 |
6 | MiracleFaFa | 3466 |
7 | slime | 3452 |
8 | maroonrk | 3422 |
9 | Radewoosh | 3406 |
10 | greenheadstrange | 3393 |
# | User | Contrib. |
---|---|---|
1 | awoo | 188 |
2 | -is-this-fft- | 187 |
3 | YouKn0wWho | 182 |
4 | Um_nik | 179 |
5 | Monogon | 178 |
6 | antontrygubO_o | 173 |
7 | maroonrk | 165 |
8 | SecondThread | 164 |
9 | SlavicG | 163 |
9 | adamant | 163 |
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
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?