問題一覧 > 通常問題

No.3424 Shooting Game

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 58
作問者 : Guran08 / テスター : まみめ syndrome harel hirayuu_yc rogi52 👑 qand kidodesu 👑 ArcAki Eku
お気に入りにしたユーザー ProblemId : 12910 / 自分の提出
問題文最終更新日: 2026-01-12 11:23:12
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 YNUCPC Contest 2 (順位表) の他の問題:

Problem Statement

Takumi is playing a shooting game. He can earn a positive score by hitting the targets that appear with bullets from his gun. A total of $N$ targets appear.
Bullets can only be fired at integer seconds. The $i$-th target appears from $L_i-0.1$ seconds to $R_i+0.1$ seconds (inclusive) after the start of the game, and it is considered hit if a bullet is fired at an integer time $t$ during this period. The score obtained in that case is $P_i$ points.
Each shot from the gun hits one target. Reloading then takes $T$ seconds, and the next bullet can be fired $T$ seconds after the shot.
Note that $T$ seconds is longer than the appearance duration of any target.
Also, a bullet is already loaded at the start of the game.
Output the maximum total score Takumi can obtain.

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • $0 \leq L_i < R_i \leq 2 \times 10^5$
  • $1 \leq P_i \leq 10^9$
  • $\max(R_i - L_i) < T \leq 2 \times 10^5$ $(1 \leq i \leq N)$
  • All inputs are integers.

Input

The input is given from standard input in the following format.

$N\ T$
$L_1\ R_1\ P_1$  
$L_2\ R_2\ P_2$  
⋮  
$L_N\ R_N\ P_N$

Output

Output the maximum total score Takumi can obtain on a single line.

Sample

Sample 1
Input
4 5
0 4 10
5 7 20
6 9 30
10 11 50
Output
90

For example, Takumi can obtain $10+30+50=90$ points in the following way.

  • Shoot the $1$-st target at $0$ seconds.
  • Shoot the $3$-rd target at $6$ seconds.
  • Shoot the $4$-th target at $11$ seconds.
The score cannot be increased any further, so the answer is $90$ points.

Sample 2
Input
5 2
1 2 1000000000
3 4 1000000000
5 6 1000000000
7 8 1000000000
9 10 1000000000
Output
5000000000

Note that the output may not fit in a 32-bit integer type.

Sample 3
Input
7 8
0 4 10
5 7 20
6 9 30
10 11 50
3 6 50
10 12 70
25 30 100
Output
220

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