1114: 硬币
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:791
Solved:339
Description
不允许普通用户打印题目,请教师登录后使用。如有疑问请联系管理员!
Input
输入包含多个测试用例。
每个测试用例的第一行包含两个整数n(1<=n<=100),m(m<=100000)。
第二行包含2n个整数,表示A1、A2、A3…An、C1、C2、C3…Cn(1</=Ai<=100000,1<=Ci<=1000)。
最后一个测试用例后面跟着两个零
Output
每组测试数据输出一个数,表示在不找零的情况下能支付多少种面值
Sample Input Copy
3 10
1 2 4 2 1 1
2 5
1 4 2 1
0 0
Sample Output Copy
8
4