#862. Watching Fireworks is Fun
Watching Fireworks is Fun
Watching Fireworks is Fun
题面翻译
一个城镇有个区域,从左到右编号为,每个区域之间距离个单位距离。 节日中有个烟火要放,给定放的地点,时间,如果你当时在区域,那么你可以获得的开心值。 你每个单位时间可以移动不超过个单位距离。 你的初始位置是任意的(初始时刻为),求你通过移动能获取到的最大的开心值。
题目描述
A festival will be held in a town's main street. There are sections in the main street. The sections are numbered through from left to right. The distance between each adjacent sections is .
In the festival fireworks will be launched. The -th ( ) launching is on time at section . If you are at section ( ) at the time of -th launching, you'll gain happiness value (note that the happiness value might be a negative value).
You can move up to length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to ), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness.
Note that two or more fireworks can be launched at the same time.
输入格式
The first line contains three integers , , ( ).
Each of the next lines contains integers , , ( ). The -th line contains description of the -th launching.
It is guaranteed that the condition ( 1<=i<m ) will be satisfied.
输出格式
Print a single integer — the maximum sum of happiness that you can gain from watching all the fireworks.
Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
样例 #1
样例输入 #1
50 3 1
49 1 1
26 1 4
6 1 10
样例输出 #1
-31
样例 #2
样例输入 #2
10 2 1
1 1000 4
9 1000 4
样例输出 #2
1992
Statistics
Related
In following homework: