atcoder#ABC274F. [ABC274F] Fishing
[ABC274F] Fishing
Score : points
Problem Statement
On a number line, there are fish swimming.
Fish , which has a weight of , is at the coordinate at time and moves at a speed of in the positive direction.
Takahashi will choose an arbitrary real number greater than or equal to and do the following action at time just once. Action: Choose an arbitrary real number . Catch all fish whose coordinates are between and , inclusive.
Find the maximum total weight of fish that he can catch.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
3 10
100 0 100
1 10 30
10 20 10
111
At time , fish , , and are at the coordinates , , and , respectively. Thus, the action done at this time with catches all the fish.
3 10
100 100 100
1 10 30
10 20 10
100
One optimal choice is to do the action at time with .
4 10
1000 100 10
100 99 1
10 0 100
1 1 1
1110
One optimal choice is to do the action at time with .