1028 : Xiaoming Orders Takeaway
- 时间限制Time Limit
- 1 秒Sec
- 内存限制Memory Limit
- 128 兆MB
- 提交次数Submitted
- 113 次Times
- 通过次数Solved
- 29 次Times
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
| 时间与内存Time and memory | 记这一份程序的 CPU 时间和内存峰值。题目上的时间限制、内存限制就是这一份的上限。The record is this program’s CPU time and peak memory. The limits on the problem apply to this one run. |
题目描述Description
Xiaoming likes to stay at home and takeaways are his favorate. He has accumulated n full discount coupons and wants to make an ordering plan for the next few days.
He will order a total of m takeaways on different days and wants to know the least money will be spent by using coupons wisely.
One order at a time, and at most one coupon can be used for each order.
输入格式Input
There are no more than 100 test cases.
On the first line of each test case, two integer numbers n and m are given. The number of coupons and orders.
Then n lines follow. Each line contains Ci and Di means you need to spend at least Ci to get Di price reduction when using the i-th coupon.
After that, m lines describe the price of the m takeaways. Each line contains Oi means the prise of the i-th order.
1 <= n <= 100, 1 <= m <= 100, 1 <= Di <= Ci <= 100, 1 <= Oi <= 100.
输出格式Output
For each test case output one line, the minimal cost for the orders.
样例Sample
出题Author
CSGrandeur