| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 2286 | Accepted: 866 |
Description
In a shop each kind of product has a price. For example, the price of a flower is 2 ICU (Informatics Currency Units) and the price of a vase is 5 ICU. In order to attract more customers, the shop introduces some special offers.
A special offer consists of one or more product items for a reduced price. Examples: three flowers for 5 ICU instead of 6, or two vases together with one flower for 10 ICU instead of 12.
Write a program that calculates the price a customer has to pay for certain items, making optimal use of the special offers. That is, the price should be as low as possible. You are not allowed to add items, even if that would lower the price.
For the prices and offers given above, the (lowest) price for three flowers and two vases is 14 ICU: two vases and one flower for the reduced price of 10 ICU and two flowers for the regular price of 4 ICU.
Input
Output
Sample Input
2 7 3 2 8 2 5 2 1 7 3 5 2 7 1 8 2 10
Sample Output
14
Source
/*
http://acm.pku.edu.cn/JudgeOnline/problem?id=1170
状态压缩DP
最多有5类产品,每类最多有5个,则可以将没个产品的数量用一个6进制位来表示,这样5类产品最多需要
5个六进制位来表示整个状态,一个有6 ^ 5 - 1 = 7775 个状态,所有用一个大小是7775的数组来记录
当前状态的最优价格
*/
3566



被折叠的 条评论
为什么被折叠?



