POJ 3260 The Fewest Coins
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 3959 | Accepted: 1174 |
Description
Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coins he uses to pay plus the number of coins he receives in change is minimized. Help him to determine what this minimum number is.
FJ wants to buy T (1 ≤ T ≤ 10,000) cents of supplies. The currency system has N (1 ≤ N ≤ 100) different coins, with values V1, V2, ..., VN (1 ≤ Vi ≤ 120). Farmer John is carrying C1 coins of value V1, C2coins of value V2, ...., and CN coins of value VN (0 ≤ Ci ≤ 10,000). The shopkeeper has an unlimited supply of all the coins, and always makes change in the most efficient manner (although Farmer John must be sure to pay in a way that makes it possible to make the correct change).
Input
Line 2: N space-separated integers, respectively V1, V2, ..., VN coins (V1, ...VN)
Line 3: N space-separated integers, respectively C1, C2, ..., CN
Output
Sample Input
3 705 25 50
5 2 1
Sample Output
3Hint
Source
顾客凑齐i需要的最少硬币个数 (多重背包)
店主凑齐i需要的最少硬币个数 (完全背包)
最后统计最少需要多少个硬币。。。。。判断不好上界所以数组开大点

浙公网安备 33010602011771号