#P11273. 「Diligent-OI R1 C」DlgtRank

    ID: 12310 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学贪心洛谷原创排序洛谷月赛

「Diligent-OI R1 C」DlgtRank

Problem Description

You are given a sequence a1ana_1\sim a_n of length nn. Here, the rank of aia_i is defined as the number of elements in aa that are strictly greater than aia_i, plus 11.

Now there are some operations to modify the elements in aa. Before all operations, you are given a constant kk in advance. Before each operation, aia_i is defined to be movable if and only if, after only adding kk to aia_i while keeping all other values unchanged, the rank of aia_i does not change. Otherwise, aia_i is not movable in this operation. Then this operation is: add kk to all movable numbers in the sequence.

It can be proven that after a certain number of operations, all values in aa will become movable, and once this state is reached for the first time, all subsequent operations will also stay in this state. In other words, no matter how many operations you perform, the number of times each value in aa is in the not movable state is finite.

Now you are asked: after performing this operation sufficiently many times, how many times is each value in aa in the not movable state.

Input Format

The first line contains two integers n,kn,k.

The next line contains nn integers a1ana_1\sim a_n, representing the initial sequence aa.

Output Format

Output one line with nn integers. The ii-th integer indicates how many times aia_i is in the not movable state during the operations.

3 1
1 3 4
1 1 0
6 2
1 2 5 6 7 8
4 3 3 2 1 0
8 10
1 14 5 14 19 19 8 10
5 1 4 1 0 0 3 2

Hint

Sample #1 Explanation

Initially, a1=1,a2=3,a3=4a_1=1,a_2=3,a_3=4.

After one operation, a1=2,a2=3,a3=5a_1=2,a_2=3,a_3=5. a2a_2 is not movable because if we only add 11 to a2a_2, its rank would change from 22 to 11.

After two operations, a1=2,a2=4,a3=6a_1=2,a_2=4,a_3=6. a1a_1 is not movable because if we only add 11 to a1a_1, its rank would change from 33 to 22.

After three operations, a1=3,a2=5,a3=7a_1=3,a_2=5,a_3=7. In this operation, all values are movable. It can be proven that no matter how many more operations you perform, the not movable state will never appear again.

Therefore, during the process, a1a_1 is not movable once, a2a_2 is not movable once, and a3a_3 is never not movable.

Constraints and Notes

For 100%100\% of the testdata, 1n2×1051\le n\le2\times10^5, 1k,ai1091\le k,a_i\le10^9.

Subtask ID nn\le Special Property Score
00 11 ABC 44
11 100100 C 1414
22 None 1313
33 30003000 C 1818
44 None 1616
55 2×1052\times10^5 A 66
66 BC 88
77 C 77
88 None 1414

Special property A: all aia_i are equal.

Special property B: for any i<ni<n, ai+1=ai+ka_{i+1}=a_i+k.

Special property C: for any iji\neq j, aiaja_i\neq a_j.

Translated by ChatGPT 5