#P6249. 神帖
神帖
Description
Legendary posts are distributed on some pages in the forum, and each page has at most one legendary post. Suppose the page he is currently browsing is page . One page to the left is page , and one page to the right is page , and so on. The -th legendary post is on page , and it has a specific ban time and happiness value . If he browses it after time , he cannot get its happiness value. It takes unit of time for zrl to flip one page left or right, and browsing a legendary post takes no time. Ask: what is the maximum total happiness value zrl can obtain.
Note: If he browses the -th legendary post at exactly units of time, he can still get happiness value.
Additional note: the happiness value of each legendary post can be obtained at most once.
Input Format
The first line contains an integer , indicating the number of legendary posts.
The next lines each contain three integers, representing , , and of the -th legendary post.
Output Format
One integer, the maximum happiness value zrl can obtain.
5
-5 1 5
-3 1 5
-1 1 5
1 1 5
3 2 5
4
5
-5 2 5
-3 1 5
-1 1 5
1 0 5
3 4 5
5
5
1 1 1
2 1 2
3 1 3
4 1 5
-5 5 5
5
Hint
Sample Explanation
Sample 1: $0 \rightarrow -1 \rightarrow 0 \rightarrow 1 \rightarrow 2 \rightarrow 3$
Sample 2: $0 \rightarrow -1 \rightarrow 0 \rightarrow 1 \rightarrow 2 \rightarrow 3$
Sample 3: $0 \rightarrow -1 \rightarrow -2 \rightarrow -3 \rightarrow -4 \rightarrow -5$
Constraints
| Test Point | Special Property |
|---|---|
| || | |
| all are equal | |
| none |
For of the testdata: , , , .
Hint: Two new groups of hack testdata have been added, so greedy/simulation can no longer pass.
Translated by ChatGPT 5
京公网安备 11011102002149号