0.52
It is summer in the land of Max-Flow and Lord Push-Relabel wants to build a swimming pool in the yard next to his castle, which will cost gold coins. So he is sending his invincible army to conquer some of the nearby towns. His soldiers can conquer one town per day, and afterwards they will use one of the following methods to acquire gold from it:
0.48
Taxes: the town will pay gold coins every day, starting the same day it is conquered.
Sacking: the army will get gold coins by looting the town the very same day it is conquered, but this will leave the town unable to pay taxes in the future.
Lord Push-Relabel wants to minimize the number of days to acquire the desired amount of gold . Please plan which towns to conquer, in what order, and for each conquered town whether it should be taxed or sacked.
Input consists of several cases. Every case begins with and , followed pairs . Assume , , , and .
For every case, print the minimum number of days needed to collect at least gold coins.
Input
100 1 99 100 100 1 3 99 32 2 8 17 7 14 32 2 7 14 9 17 15 3 4 6 2 7 1 2 76543210987654321 1 7654321 43210987654321
Output
1 34 3 2 2 10000000130