This is the problem link. This is my submission. It is getting TLE. I read another guy's recursive approach. It got full points. I don't understand, why this code is getting accepted, but mine is not.
Any help would be really appreciated.
Peace.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
This is the problem link. This is my submission. It is getting TLE. I read another guy's recursive approach. It got full points. I don't understand, why this code is getting accepted, but mine is not.
Any help would be really appreciated.
Peace.
Name |
---|
Please explain your approach.
dfs(level, pos) returns the maximum value possible from that level, if we use the element at 'pos' as the last element of the level.
You should no use recursive approach. This question can be solved in O(m1+m2+m3+....) where mi is the number of ingredients in the ith dish, you can see my code https://www.codechef.com/viewsolution/15833805 I used the logic that only maximum or minimum number in the previous dish will cause the highest quality hence check which one should be used it's kind of greedy approach.
But, the solution I mentioned above has solved it using recursive approach using DP. Can someone explain that?
Can you prove your greedy approach?