问题 B: Make the Farm great again
题目描述
Bessie, the chairman of the United Farm of Amoorica, will ends its term in January. An election is being held with N candidates numbered 1,2,…,$N$.
There are K votes, some of which have been counted so far. Up until now, candidate $i$ has received $A_i$ votes.
After all ballots are counted, candidate i ($1 \le i \le N $) will be elected if and only if the number of candidates who have received more votes than them is less than $M$. There may be multiple candidates elected
For each candidate, find the minimum number of additional votes they need from the remaining ballots to guarantee their victory regardless of how the other candidates receive votes.
Formally, solve the following problem for each .
Determine if there is a non-negative integer $X$ not exceeding $K-\sum_{i=1}^N A_i$ satisfying the following condition. If it exists, find the minimum possible such integer.
- If candidate receives additional votes, then candidate will always be elected.
注意:输出的最后不要带空格。
输入
The input is given from Standard Input in the following format:
$N \qquad M \qquad K$
$A_1 \qquad A_2 \qquad ... \qquad A_N$
输出
If candidate has already secured their victory, then let $C_i = 0$ . If candidate cannot secure their victory under any circumstances, then let $C_i = -1$.
样例输入
5 2 16
3 1 4 1 5
样例输出
2 -1 1 -1 0
提示
For the sample output,
votes have been counted so far, and votes are left.
The to output is . For example:
- Candidate can secure their victory by obtaining more votes, while not by obtaining more vote. Thus, .
- Candidate can never (even if they obtain more votes) secure their victory, so .
- $1 \le M \le N \le 2*10^5$
- $1 \le K \le 10^{12}$
- $0 \le A_i \le 10^{12}$
- $\sum_{i=1}^N A_i \le K $
- All input values are integers.