问题 B: Make the Farm great again

文件提交:无需freopen 内存限制:1024 MB 时间限制:2.500 S
评测方式:普通裁判 命题人:
提交:31 解决:3

题目描述

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 i=1,2,,N.

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 i receives X additional votes, then candidate i 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$

输出

Let $C_i$ be the minimum number of additional votes candidate  needs from the remaining ballots to guarantee their victory regardless of how other candidates receive votes. Print $C_1,C_2,...,C_N$ separated by space.

If candidate i has already secured their victory, then let $C_i = 0$ . If candidate i 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 2 votes are left.
The C to output is (2,1,1,1,0). For example:

  • Candidate 1 can secure their victory by obtaining 2 more votes, while not by obtaining 1 more vote. Thus, C1=2.
  • Candidate 2 can never (even if they obtain 2 more votes) secure their victory, so C2=1.


Constraints

  • $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.