https://atcoder.jp/contests/abc364/tasks/abc364_e Recent at coder problem.
I really can't process this problem, may be because it is 3D, can anyone explain it? Or suggest me similar problems where we need to work with 3 variables.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
https://atcoder.jp/contests/abc364/tasks/abc364_e Recent at coder problem.
I really can't process this problem, may be because it is 3D, can anyone explain it? Or suggest me similar problems where we need to work with 3 variables.
Name |
---|
This was my submission ->
My submission
I have added some comments in the above submission to make it easier to understand.
Basically, you first of all make the observation that n is 80. And that the standard dp knapsack approach won't work as the x and y range to 1e5, thereby giving MLE and Runtime error for 3D dp table.
So what you do to tackle it is, instead of thinking of maximizing the number of dishes, you try to minimize the saltiness value for each sweetness value from 0 to x. Once you have done that, you can see that all you need to do is print the maximum number of dishes which has saltiness lesser than or equal to the given max tolerable value of saltiness
Your code is readable for me ,was searching for it,thanks a lot
By the way ,do you know any similar problem? How you come up with this solution like swapping state?
I was sadly not able to solve the question in contest, and had to read the editorial only to get the idea :(
I myself am just beginner in dp, so I am not aware of many such problems :(
this is something i learned lately whenever u have a dp lets say for this problem its bool dp[ans][sweetness][saltiness] change the dp to int or anything that fits instead of bool and take away one of the states for example we can say dp[sweetness][salitness] max ans for these 2 but its not optimal for this problem as both sweetness and saltiness go up to 1e4 but the answer doesnt so instead remove one of the 1e4 states and add the answer which only takes 80 so now we have dp[i][j] minimum saltiness for the answer to be i and sweetness to be j same solution but its up to you on which state u take away also its not always the bigger states sometimes its helpful to take away a small one if taking away the bigger one makes the implementation harder although in some problems u need the smallest states also for this problem i think a sorting greedy idea works in making the dp linear
anyways here is my submission
https://atcoder.jp/contests/abc364/submissions/56097091
thanks man <3
Can u suggest me more similar problems?
had to use my mobile data to get into them,thank you for the problems, would love to solve them
unable to find the last problem "breaking toys" in the problemset
Sorry, I gave the wrong link. I've updated it. Please check now.
thanks
finally solved ,thank you to all for helping (https://atcoder.jp/contests/abc364/submissions/56107986)