luogu#P4266. [USACO18FEB] Rest Stops S
[USACO18FEB] Rest Stops S
题目描述
Farmer John and his personal trainer Bessie are hiking up Mount Vancowver. For their purposes (and yours), the mountain can be represented as a long straight trail of length meters (). Farmer John will hike the trail at a constant travel rate of seconds per meter (). Since he is working on his stamina, he will not take any rest stops along the way. Bessie, however, is allowed to take rest stops, where she might find some tasty grass. Of course, she cannot stop just anywhere! There are rest stops along the trail (); the -th stop is meters from the start of the trail () and has a tastiness value (). If Bessie rests at stop for seconds, she receives tastiness units.
When not at a rest stop, Bessie will be hiking at a fixed travel rate of seconds per meter (). Since Bessie is young and fit, is strictly less than .
Bessie would like to maximize her consumption of tasty grass. But she is worried about Farmer John; she thinks that if at any point along the hike she is behind Farmer John on the trail, he might lose all motivation to continue!
Help Bessie find the maximum total tastiness units she can obtain while making sure that Farmer John completes the hike.
输入格式
The first line of input contains four integers: , , , and . The next lines describe the rest stops. For each between and , the -st line contains two integers and , describing the position of the -th rest stop and the tastiness of the grass there. It is guaranteed that , and . Note that and are given in seconds per meter!
输出格式
A single integer: the maximum total tastiness units Bessie can obtain.
题目大意
题目描述
Farmer John 和他的私人教练 Bessie 正在攀登温哥华山。为了他们的目的(以及你的目的),这座山可以表示为一条长度为 米的长直步道()。Farmer John 将以每米 秒的恒定速度徒步()。由于他正在锻炼耐力,他不会在途中休息。
然而,Bessie 被允许在休息站休息,她可能会在那里找到一些美味的草。当然,她不能随便停下来!步道上有 个休息站();第 个休息站距离步道起点 米(),并且有一个美味值 ()。如果 Bessie 在第 个休息站休息 秒,她会获得 的美味单位。
当不在休息站时,Bessie 将以每米 秒的固定速度徒步()。由于 Bessie 年轻且健康, 严格小于 。
Bessie 希望最大化她摄入的美味草量。但她担心 Farmer John;她认为如果在徒步的任何时刻她在步道上落后于 Farmer John,他可能会失去继续前进的动力!
请帮助 Bessie 找到在确保 Farmer John 完成徒步的情况下,她能获得的最大总美味单位。
输入格式
输入的第一行包含四个整数:、、 和 。接下来的 行描述了休息站。对于每个 从 到 ,第 行包含两个整数 和 ,分别描述第 个休息站的位置和草的美味值。 保证 ,且 。注意, 和 的单位是秒每米!
输出格式
输出一个整数:Bessie 能获得的最大总美味单位。
提示
在这个例子中,Bessie 最优的策略是在 的休息站休息 秒(获得 个美味单位),然后在 的休息站再休息 秒(获得 个美味单位,总共 个美味单位)。
10 2 4 3
7 2
8 1
15
提示
In this example, it is optimal for Bessie to stop for seconds at the rest stop (acquiring tastiness units) and then stop for an additional second at the rest stop (acquiring more tastiness unit, for a total of tastiness units).
Problem credits: Dhruv Rohatgi