Problem link: https://mirror.codeforces.com/contest/1472/problem/E
Submission link: https://mirror.codeforces.com/contest/1472/submission/165709605
# | 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 |
Problem link: https://mirror.codeforces.com/contest/1472/problem/E
Submission link: https://mirror.codeforces.com/contest/1472/submission/165709605
Name |
---|
I can't really understand what's the purpose of
cj
.a[i] != a[i - 1]
is always true, because all pairs ina
also contain their index in initial array.Probably got its meaning. You need to check if
a[i].fi.fi != a[i - 1].fi.fi
and also you don't need to always updatecj
. You also need to check ifa[cj].fi.se > a[ci].fi.se
when updating. I changed it in your code and it got accepted.165772947
Why is this necessary? ci is always containing the least value so we can directly update cj to ci if we can. Can you provide some test case or argument why was this necessary?
First of all, I need to ask you smth. Am I right, that
cj
contains the index of the smallest by width box that has height which is less (not less or equal, but less) than the current? (if we sort our boxes by height).Yup, you are right, my bad. Checking whether
ci
is better thancj
is not necessary.Yes, that's the correct meaning of cj. But why is your code giving AC but mine is giving WA?
The point is that, as I said, that you are not really checking what you want.
a[i] != a[i - 1]
is always true, asa[i]
is a tuple{h, w, id}
andid
is unique for everya[i]
. You need to check thata[i - 1].h != a[i].h
. I changed got so it does (and also added useless checka[cj].fi.se > a[ci].fi.se
) and it got accepted.Thank you so much
:)
P.S: Please work on your codestyle :)
Alt of adityagamer?
Yes
smh. why?