#P6602. 「EZEC-2」数轴

「EZEC-2」数轴

Description

X drew a number line. He will perform nn operations. In each operation, he first adds aia_i marks at position xix_i on the number line.

Then he needs to choose a pair (l,r)(l,r), where l,rl,r are integers, 0lrm0\le l\le r \le m, and the number of marks on the interval [l,r][l,r] on the number line is less than or equal to kk.

For each operation, you need to find the maximum value of rlr-l among all pairs (l,r)(l,r) that satisfy the condition.

Input Format

The first line contains three integers, nn, mm, and kk.

The next nn lines each contain two integers xix_i and aia_i.

Output Format

Output nn lines, where the ii-th line is the answer after the ii-th operation.

If there is no valid pair (l,r)(l,r), output -1.

5 4 0
2 1
3 1
0 1
1 1
4 1
1
1
0
0
-1
5 15 1
3 1
8 1
1 1
7 1
14 1
15
11
11
7
6

10 100 10
94 3
22 10
9 4
37 1
21 10
92 5
50 9
68 8
44 4
78 9

100
93
83
77
77
77
68
44
40
26

10 100 3
95 1
13 1
52 1
74 1
40 1
54 1
71 1
68 1
51 3
12 2

100
100
100
94
80
59
56
53
50
39

Hint

[Sample Explanation #2]

After each operation, the chosen pairs are (0,15),(4,15),(4,15),(8,15),(9,15)(0,15),(4,15),(4,15),(8,15),(9,15).


[Constraints and Notes]

Test Point ID n=n= m=m= k=k=
1,21,2 100100 100100 33
3,43,4 10310^3
5,65,6 10410^4
7,87,8 500500
9,109,10 10310^3
11,1211,12 10410^4 10510^5
131613\sim 16 10510^5 10610^6 00
172117\sim 21 33
22,2322,23 10910^9 100100
24,2524,25 10610^6

It is guaranteed that for test points 131613\sim 16, xix_i is generated randomly.

For test points 24,2524,25, the time limit is 3s3\text s, and for all other test points, the time limit is 2s2\text s.

For 100%100\% of the data, 1n1061\le n\le 10^6, 0m1090\le m\le 10^9, 0xim0\le x_i\le m, 0k1000\le k\le 100, and 1ai1001\le a_i\le 100.

Note: Marks may be added multiple times at the same position on the number line.

O2\text{O2} optimization is enabled automatically. It is guaranteed that the time and memory limits are both more than twice those of std\text{std} with O2\text{O2} enabled.

Translated by ChatGPT 5