問題一覧 > 通常問題

No.1826 Fruits Collecting

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 55
作問者 : IKyopro / テスター : torisasami4
お気に入りにしたユーザー ProblemId : 5346 / 自分の提出
問題文最終更新日: 2022-01-21 21:47:43
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 329 (順位表) の他の問題:

Problem Statement

Umg is at coordinate $0$ on a $1$-dimensional line. The current time is $0$. Umg has decided to collect fruits falling from the sky. Each time the time advances by $1$, Umg can choose to move to the coordinate $1$ greater, move to the coordinate $1$ smaller, or stay in place. It is known that $N$ fruits in total will fall, numbered from $1$ to $N$. The $i$-th fruit has value $V_i$ and falls at position $X_i$ at time $T_i$. Umg can obtain the $i$-th fruit only if he is at position $X_i$ at time $T_i$ (including the case where he arrives exactly at that time).

When Umg moves optimally, what is the maximum possible total value of the fruits he obtains?

Input

$N$
$T_1 \ X_1 \ V_1$
$T_2 \ X_2 \ V_2$
$\vdots$
$T_N \ X_N \ V_N$

  • $1\leq N \leq 2\times 10^5$
  • $1\leq T_i \leq 10^9$
  • $-10^9\leq X_i \leq 10^9$
  • $1\leq V_i \leq 10^9$

Output

Output the answer on one line. Print a newline at the end.

Sample

Sample 1
Input
3
2 2 5
4 -3 10
7 6 12
Output
17

It is optimal to obtain fruit 1 and fruit 3.

Sample 2
Input
2
3 5 100000
10 -12 10000000
Output
0

Sample 3
Input
10
714285999 -270646698 674821981
145453038 -493065708 578571371
182454287 559505745 613524283
91187113 58976167 387606995
161055320 603771484 957805357
859495351 829271084 788215467
206954118 -473864425 246246653
371344794 -579231472 433788627
205330018 -483888481 20249846
440000042 164167853 119221407
Output
1062428976

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