I solved it using sorting + dp. In tags it is 'binary search' + 'sorting'. Couldn't think of binary search solution.
BTW, size limit is 10^6 and not 10^5.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | 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 | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Name |
---|
First of all I think it will be better to write to link and not only problem name (maybe I'm wrong, but I do not know how to search problems by name).
Here is the link (I think you are talking about): 101C Queue.
Maybe I'm looking on different problem, but tags I see are: "constructive algorithms", "greedy", "sortings" and limit (for h_i) in this problem is 10^9.
Ok, my bad.
this is the problem : Queue
For each position on the queue calculate the youngest person from that position to the end. You can do binary search to find the farthest place on the queue such that this min is less than the age of the current walrus, which is the position of the farthest walrus that is younger than the i-th one.
Thanks for that.