Could anyone from the codeforces community help me solve this problem? Any kind of help will be appreciated. Thankyou in anticipation. https://codeforces.net/gym/101149/problem/E -> This is the problem link.
# | 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 | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Could anyone from the codeforces community help me solve this problem? Any kind of help will be appreciated. Thankyou in anticipation. https://codeforces.net/gym/101149/problem/E -> This is the problem link.
Name |
---|
You are only allowed to assign scores within the range of each contestant.
You want to maximize the number of contestants with the maximum score.
So consider the result if you decide the maximum score is the max $$$r_i$$$ value at first.
Then try lowering it by one repeatedly and each time consider which contestants can join the group of winners. At a certain point you cannot lower it any further without breaking the scoring conditions of at least one of the contestants.
Generally when working with intervals it can be helpful to view them after sorting them by starting point, end point, size or slack ($$$r_i - l_i$$$).
if possible could you please provide me with the code?
You gain more by implementing yourself. But here it is:
Thankyou!
It is rather easy to solve if you know what dynamic segment tree is. In fact, this is segment tree which supports the same operations as per usual segment tree do, but you can expand value's bounds (in this task you can store all segments from -1e9 to 1e9). If you have such a structure, all you have to do is to add +1 to each number of each segment (using lazy propagation in segment tree) and take maximum over all values in your tree which are bigger than smallest bound of all segments.
P.S. dynamic segment tree usually works like a coordinate compression, but if you're using first way, you should simply copy-paste structure, while in the second way you should "integrate" compression into your code.
if possible could you please provide me with the code?