#P12636. [UOI 2020] Array Reduction

[UOI 2020] Array Reduction

题目描述

Given an array aa consisting of nn integers. For one operation, you can choose position ii (1in1 \leq i \leq n), decrease aia_i by kk, and increase the value of all other elements aja_j (1jn,ij1 \leq j \leq n, i \neq j) by tt.

Find the minimum number of operations needed to make all elements of the array less than or equal to zero (i.e., non-positive), or report that it is impossible to do so.

输入格式

The first line contains three integers nn, kk, tt (1n1061 \leq n \leq 10^6, 0k,t1090 \leq k, t \leq 10^9) --- the length of the array and the operation parameters.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1018ai109-10^{18} \leq a_i \leq 10^9) --- the initial values of the array elements.

输出格式

Output a single integer cc --- the minimum number of operations needed to make all elements of the array less than or equal to zero. If it is impossible, output 1-1.

If it is possible, output nn integers cnticnt_i (1in1 \leq i \leq n), which represent the number of operations performed on the element with index ii. Note that the equality i=1ncnti=c\sum\limits_{i=1}^n cnt_i = c must hold.

4 10 1
2 5 9 -4
4
1 1 2 0 
5 1 100
-1000 -1000 10 -1000 -1000
10
0 0 10 0 0 
2 1 1
1 0
-1

提示

  • (33 points) t=0t = 0;
  • (55 points) $1 \leq n \leq 300, 0 \leq |a_i| \leq 300, 0 \leq t \leq 10^6$;
  • (88 points) $1 \leq n \leq 3000, 0 \leq |a_i| \leq 3000, 0 \leq t \leq 10^6$;
  • (99 points) $1 \leq n \leq 10^3, 1 \leq a_i \leq 10^9, 0 \leq t \leq 10^6$;
  • (55 points) 1n104,1ai1091 \leq n \leq 10^4, 1 \leq a_i \leq 10^9;
  • (1313 points) 1n105,1ai1091 \leq n \leq 10^5, 1 \leq a_i \leq 10^9;
  • (88 points) 1ai1091 \leq a_i \leq 10^9;
  • (99 points) 1n103,0t1061 \leq n \leq 10^3, 0 \leq t \leq 10^6;
  • (55 points) 1n1041 \leq n \leq 10^4;
  • (1414 points) 1n1051 \leq n \leq 10^5;
  • (2121 points) without additional constraints.