https://codeforces.me/contest/4/submission/174376175
My code:Check if sumtime is in $$$[minsum,maxsum]$$$,minsum is the sum of all the $$$mintime$$$ and maxsum is the sum of all the $$$maxtime$$$.Then greedy for the solution.
# | User | Rating |
---|---|---|
1 | jiangly | 3898 |
2 | tourist | 3840 |
3 | orzdevinwang | 3706 |
4 | ksun48 | 3691 |
5 | jqdai0815 | 3682 |
6 | ecnerwala | 3525 |
7 | gamegame | 3477 |
8 | Benq | 3468 |
9 | Ormlis | 3381 |
10 | maroonrk | 3379 |
# | User | Contrib. |
---|---|---|
1 | cry | 168 |
2 | -is-this-fft- | 165 |
3 | Dominater069 | 161 |
4 | Um_nik | 160 |
5 | atcoder_official | 159 |
6 | djm03178 | 157 |
7 | adamant | 153 |
8 | luogu_official | 151 |
9 | awoo | 149 |
10 | TheScrasse | 146 |
https://codeforces.me/contest/4/submission/174376175
My code:Check if sumtime is in $$$[minsum,maxsum]$$$,minsum is the sum of all the $$$mintime$$$ and maxsum is the sum of all the $$$maxtime$$$.Then greedy for the solution.
Name |
---|
Not sure if greedy is applicable here, though I solved it with knapsack-like dp. Could you elaborate on your solution?
you are so close my guy. I took your code and only changed one thing. This is my submission: https://codeforces.me/contest/4/submission/178599913
can you spot what i noticed?
your first if condition in the while loop
`
when you update sumtime
you set sumtime to suntime — (maxtime[j] + mintime[j]) — why do you do this? The correct thing to do is to set sumtime to sumtime — (maxtime[j] — mintime[j]) — this is because at the start you have already taken away mintime[j] from sumtime, therefore, using maxtime[j] hours on the jth day means that you only have to takeaway (maxtime[j]-mintime[j]) more hours from sumtime.
hope this helps