Wuzhangyuan
Time limit2sMemory limit1024 MB
Given X, K, and C, find the minimum total cost to send X supplies in attempts costing a+C each, when Sima Yi blocks up to K attempts to maximize the cost.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Game theory, Binary search
- Solved
- No attempts yet
Statement
In 234 CE, Zhuge Liang of Shu commits the full strength of the state to a final northern campaign. After three years of preparation, the expedition army numbers about 100,000, the second largest Shu northern force after the Battle of Yiling. Sima Yi of Wei hears the news and immediately moves to stop him. Hearing that Zhuge Liang will come through Ye Valley, Sima Yi moves to Meixian (眉縣). Then he watches to see whether Zhuge Liang heads to Wugong (武功) or Wuzhangyuan (五丈原).
"If Zhuge Liang is a bold man, he will surely leave Wugong and advance east along the mountains. If he goes west and climbs Wuzhangyuan, the entire army (諸軍) will be safe."
Zhuge Liang is cautious, so he directs his troops to Wuzhangyuan, and the Shu and Wei armies clash there.
Zhuge Liang of Shu and Sima Yi of Wei face each other at Wuzhangyuan. Zhuge Liang makes several supply runs to send a total of of supplies to the army in the field.
Zhuge Liang can attempt to send a positive integer of supplies in one attempt, and this costs .
Sima Yi can block up to of Zhuge Liang's supply attempts. A blocked attempt costs Zhuge Liang only the expense, and the supplies are lost.
Zhuge Liang wants to send a total of of supplies at the minimum cost, while Sima Yi blocks attempts so that Zhuge Liang spends the maximum cost. Both strategists do their utmost to achieve their goals. Compute the minimum cost for Zhuge Liang to deliver all of supplies.
Input
The first line contains three positive integers , , and , separated by spaces.
is the target amount of supplies Zhuge Liang wants to send.
is the maximum number of supply attempts Sima Yi can block.
is the cost Zhuge Liang pays for each supply attempt. Specifically, an attempt to send costs .
Output
Print the minimum cost for Zhuge Liang to send all of supplies on the first line.