118 - ZOJ Monthly, July 2012 - B
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense tower, which has L longevity. The player has a military factory, which can produce N kinds of battle ships. The factory takes ti seconds to produce the i-th battle ship and this battle ship can make the tower loss li longevity every second when it has been produced. If the longevity of the tower lower than or equal to 0, the player wins. Notice that at each time, the factory can choose only one kind of battle ships to produce or do nothing. And producing more than one battle ships of the same kind is acceptable.
Your job is to find out the minimum time the player should spend to win the game.
There are multiple test cases.
Output one line for each test case. An integer indicating the minimum time the player should spend to win the game.
1 1 1 1 2 10 1 1 2 5 3 100 1 10 3 20 10 100
2 4 5
Author: FU, Yujun