HINT 1
HINT 2
HINT 3
HINT 1
HINT 2
HINT 3
HINT 4
HINT 1
HINT 2
5A. K-th Number in the Union of Segments
HINT 1
HINT 1
HINT 2
HINT 1
HINT 2
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Average should be in double not int or long long.
Any length is ok as long as the average is maximum.
Try a test case that all number is 0.
It is a DAG so we can use top sort + DP to get shortest path.
Binary search for the average, minus average on every edge.
If the shortest path is <= 0, it means we can have an even lower average. If the shortest path is > 0, it means this average is too high. Note, we don't need to find a path that is exactly 0 cost. Binary search will help us narrow down.
1 might not be the only source, so we need to push all in degree 0 to queue first.
(a+b)/(c+d) > m => a+b > (c+d)*m => a-m*c + b-m*d > 0
Binary search for m.
5A. K-th Number in the Union of Segments
Just follow what theory says
k should be 0 indexed for the theory, so [1, n^2] becomes [0, n^2-1]. Because cnt(x) could return 0, we need k to start from 0, otherwise 1 will be skipped.
There is a trick to get O(n) for cnt(x). Start from bottom left and count towards upper right, if mid > i*j, move j, otherwise move i.
k should be 0 indexed.
Sort both array and use two pointers method for cnt(x). Start from 0 of first array and start from n-1 of second array.
Название |
---|
have you read the terms of agreement?
Personally I don't see the point of the agreement.
USELESS ALGORITHM
that's why you are a newbie