#P9587. 「MXOI Round 2」排名
「MXOI Round 2」排名
Problem Description
Xiao C has an array of length .
Xiao C defines as the front rank of , where equals the number of elements in array that are greater than , plus .
Xiao C also defines as the back rank of , where equals the number of elements in array that are greater than or equal to .
In each operation, Xiao C needs to choose a positive integer not greater than , and increase the value of by .
Xiao C wants to know, for each , in order to make hold, what is the minimum number of operations needed?
It can be proven that there is always at least one sequence of operations that makes .
Input Format
The first line contains three integers , where indicates the test point ID. means this test point is the sample.
The second line contains integers, representing the given array .
Output Format
Output lines in total, each containing one integer. The integer on line indicates the minimum number of operations needed to make hold.
0 6 3
1 1 4 5 1 4
3
3
0
2
3
0
Hint
Sample Explanation #1
When , Xiao C can choose and perform operations. Then and , satisfying . It can be proven that Xiao C needs at least operations in this case.
When , Xiao C can first choose and perform operation, then choose and perform operation. Then and , satisfying . It can be proven that Xiao C needs at least operations in this case.
Sample #2
See rank/rank2.in and rank/rank2.ans in the attachment.
This sample satisfies the constraints of test point .
Sample #3
See rank/rank3.in and rank/rank3.ans in the attachment.
This sample satisfies the constraints of test point .
Constraints
For of the data, , and .
| Test Point ID | Special Property | ||
|---|---|---|---|
| A | |||
| None | |||
| B | |||
| None |
Special Property A: It is guaranteed that for all , holds.
Special Property B: It is guaranteed that .
Translated by ChatGPT 5