[ABC485F] 大桥减价 (Big Bridge)
Score : points
Problem Statement
There are items , one of each. Item has a price of and a value of .
Each time Takahashi crosses a bridge, the price of every item whose price is at least decreases by .
For each , find the following value.
- The maximum possible total value of the chosen items when, after Takahashi has crossed the bridge times, zero or more items are chosen so that their total price is at most .
Constraints
-
-
-
-
All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $M$
$c_1$ $v_1$
$c_2$ $v_2$
$\vdots$
$c_N$ $v_N$
Output
Print the answers in lines in total. The -th line should contain the answer for .
Sample Input 1
3 4
1 3
2 5
4 8
Sample Output 1
8
16
16
16
16
For , the prices of all items remain as they were initially. Choosing items and makes the total value , which is the maximum possible.
For , the prices of all items decrease by . Choosing items , , and makes the total value , which is the maximum possible.
Sample Input 2
5 6
4 6
4 7
6 11
2 4
1 2
Sample Output 2
11
17
24
30
30
30
30
Sample Input 3
2 1
1 4
1 7
Sample Output 3
7
11