354 传统题

[ABC485F] 大桥减价 (Big Bridge)

时间限制
2000ms
内存限制
1024MiB
登顶 / 尝试
1/ 1
难度
6
    上传者 标签AtCoderABC 485提高+动态规划背包

[ABC485F] 大桥减价 (Big Bridge)

Score : 525525 points

Problem Statement

There are NN items 1,2,…,N1,2,\dots,N, one of each. Item ii has a price of cic_i and a value of viv_i.

Each time Takahashi crosses a bridge, the price of every item whose price is at least 11 decreases by 11.

For each j=0,1,…,Mj=0,1,\dots,M, find the following value.

  • The maximum possible total value of the chosen items when, after Takahashi has crossed the bridge jj times, zero or more items are chosen so that their total price is at most MM.

Constraints

  • 1≤N≤1021 \leq N \leq 10^2

  • 1≤ci≤M≤1041 \leq c_i \leq M \leq 10^4

  • 1≤vi≤1091 \leq v_i \leq 10^9

  • 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 M+1M+1 lines in total. The kk-th line should contain the answer for j=k−1j=k-1.

Sample Input 1

3 4
1 3
2 5
4 8

Sample Output 1

8
16
16
16
16

For j=0j=0, the prices of all items remain as they were initially. Choosing items 11 and 22 makes the total value 88, which is the maximum possible.

For j=1j=1, the prices of all items decrease by 11. Choosing items 11, 22, and 33 makes the total value 1616, 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