bzoj#P2020. [USACO2010 Jan] Buying Feed, II
[USACO2010 Jan] Buying Feed, II
题目描述
Farmer John needs to travel to town to pick up pounds of feed. Driving miles with pounds of feed in his truck costs cents. The county feed lot has stores (conveniently numbered ) that sell feed. Each store is located on a segment of the axis whose length is . Store is at location on the number line and can sell FJ as much as pounds of feed at a cost of cents per pound. Amazingly, a given point on the axis might have more than one store. FJ starts at location on this number line and can drive only in the positive direction, ultimately arriving at location , with at least pounds of feed. He can stop at any of the feed stores along the way and buy any amount of feed up to the the store's limit. What is the minimum amount FJ has to pay to buy and transport the pounds of feed? FJ knows there is a solution. Consider a sample where FJ needs two pounds of feed from three stores (locations: ) on a number line whose range is :
0 1 2 3 4 5
+---|---+---|---|---+
1 1 1 Available pounds of feed
1 2 2 Cents per pound
It is best for FJ to buy one pound of feed from both the second and third stores. He must pay two cents to buy each pound of feed for a total cost of . When FJ travels from to he is moving unit of length and he has pound of feed so he must pay cents. When FJ travels from to he is moving one unit and he has pounds of feed so he must pay cents. The total cost is cents.
FJ 开车去买 份食物,如果他的车上有 份食物。每走一里就花费 元。FJ 的城市是一条线,总共 里路,有 个地方,标号 。FJ 从 开始走,到 结束(不能往回走),要买 份食物。城里有 个商店,每个商店的位置是 (一个点上可能有多个商店),有 份食物,每份 元。问到达 并买 份食物的最小花费。
输入格式
第一行:。
第二行到第 行:。
输出格式
没有写明输出格式。
2 5 3
3 1 2
4 1 2
1 1 1
7
样例说明 1
在离家较近的两家商店里各购买一吨饲料,则花在路上的钱是 ,花在店里的钱是 。
数据规模与约定
对于 的数据,,,,,,。
题目来源
Silver