#P4544. [USACO10NOV] Buying Feed G
[USACO10NOV] Buying Feed G
Description
John drives to town and wants to bring back tons of feed. Transporting feed costs money: if his car currently carries tons, the cost per kilometer is yuan, so driving kilometers costs yuan. John can buy feed from stores, all located on a number line. Store is at position , sells feed at yuan per ton, and has tons in stock.
John starts at and travels in the positive direction along the axis. His home is at . What is the minimum total cost for John to bring tons of feed home? Assume the sum of all stores’ stocks is at least .
For example, suppose there are three stores as shown below:
| Coordinate | ||||
|---|---|---|---|---|
| Stock | ||||
| Price | ||||
If , John’s optimal choice is to buy from the two stores closer to home. The money spent on the road is , the money spent at the stores is , for a total of yuan.
Input Format
The first line contains three integers , , .
Lines to : line contains three integers , , .
Output Format
Output a single integer, the minimum total cost.
2 5 3
3 1 2
4 1 2
1 1 1
9
Hint
Constraints
, , .
, , .
Translated by ChatGPT 5
京公网安备 11011102002149号