No.2808 Concentration
タグ : / 解いたユーザー数 36
作問者 :
watasou1543
/ テスター :
Magentor
highlighter
keisuke6
fact493
Problem Statement
watasou is attending a class.
Since watasou can foresee the future, he knows that Professor warabi will give $N$ important talks. Taking the start of the class as $0$ minutes, the $i$-th important talk runs from $X_i+10^{100}+0.01$ minutes to $Y_i+10^{100}-0.01$ minutes, and by listening to it from beginning to end he gains $Z_i$ knowledge.
watasou can listen to the class if and only if he is awake. Since watasou cannot keep his concentration during Professor warabi's class, he can stay awake for at most $S$ consecutive minutes. Also, once he falls asleep, he cannot wake up for at least $H$ minutes.
When watasou can freely decide the times at which he sleeps and wakes under the above conditions, find the maximum possible total knowledge he can gain.
Input
The input is given from Standard Input in the following format.$N ~~~ S ~~~ H$
$X_{1} ~~~ Y_{1}~~~ Z_{1}$
$X_{2} ~~~ Y_{2} ~~~ Z_{2}$
$~~~~~~~~ \vdots$
$X_{N} ~~ Y_{N} ~~ Z_{N}$
Constraints
- $1 \leq N \leq 2×10^5$
- $1 \leq S,H \leq 10^9$
- $0 \leq X_{i} \lt Y_{i} \leq 10^{9} \left( 1 \leq i \leq N\right)$
- $Y_{i} \lt X_{j} \left(1 \leq i \lt j \leq N \right)$
- $1 \leq Z_i \leq 10^9$
- All input values are integers.
Output
Output the answer.
Sample
Sample 1
Input
4 2 2 1 3 4 5 8 6 9 11 5 12 13 2
Output
9
He can gain $9$ knowledge by acting as follows.
- Sleep for $10^{100}+1.01$ minutes.
- Listen to the $1$st talk, increasing his knowledge by $4$.
- Sleep for $6.02$ minutes.
- Listen to the $3$rd talk, increasing his knowledge by $5$.
Note that the $2$nd talk lasts $2.98$ minutes, so he cannot listen to it from beginning to end.
Sample 2
Input
1 1 1 0 100 100
Output
0
Sample 3
Input
3 3 4 0 3 4 5 8 7 11 12 5
Output
9
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。