問題一覧 > 通常問題

No.2701 A cans -> B cans

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 65
作問者 : Magentor / テスター : 👑 hamamu hirayuu_yc
お気に入りにしたユーザー ProblemId : 10272 / 自分の提出
問題文最終更新日: 2024-03-29 21:52:24
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 424 (順位表) の他の問題:

Problem Statement

Solve the following problem independently for each of $p=1,2,\dots,M$.

Magentor has $p$ empty cans $0$.

There are also $N$ shops. At the $i$-th shop, he can hand over a total of $A_i$ cans, each of which is an empty can $0$ or an empty can $i$, and receive $B_i$ juice-filled cans $i$ in exchange. Here, $A_i>B_i$ is guaranteed.

By drinking the juice, Magentor can turn $1$ juice-filled can $i$ into $1$ empty can $i$. When he does so, he gains $C_i$ happiness.

Find the maximum total happiness Magentor can obtain.

Input

$N\ M$
$A_1\ B_1\ C_1$
$A_2\ B_2\ C_2$
$\vdots$
$A_N\ B_N\ C_N$
  • $1\leq N\leq 5000$
  • $2\leq M\leq 5000$
  • $1\leq B_i<A_i\leq M$
  • $1\leq C_i\leq 10^9$
  • All input values are integers.

Output

Output $M$ lines.

On the $i$-th line, output the answer for $p=i$.

Sample

Sample 1
Input
2 5
4 3 3
5 2 8
Output
0
0
0
9
18

When $p=5$, Magentor initially has $5$ empty cans $0$. He can make the total happiness $18$ as follows.

  • At shop $1$, exchange $4$ empty cans $0$ for $3$ juice-filled cans $1$.
  • Turn the $3$ juice-filled cans $1$ into $3$ empty cans $1$. He gains $9$ happiness.
  • At shop $1$, exchange $1$ empty can $0$ and $3$ empty cans $1$ for $3$ juice-filled cans $1$.
  • Turn the $3$ juice-filled cans $1$ into $3$ empty cans $1$. He gains $9$ happiness.

The total happiness cannot be made $19$ or more no matter what he does, so the answer for $p=5$ is $18$.

Sample 2
Input
1 2
2 1 1000000000
Output
0
1000000000
Sample 3
Input
3 10
9 8 1
5 1 8
5 2 4
Output
0
0
0
0
8
8
8
16
16
16

Note that empty cans $1$ cannot be exchanged at shop $2$ or shop $3$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。