-->
当前位置:首页 > 题库

PROGRAMMING:Double 11: a headache

Luz5年前 (2021-05-10)题库431
Double 11 is coming, online shopping otaku Xiaoming boxing huohuohuo! Ideal is full, reality is bony. Although Xiao Ming added a lot of items to the shopping cart, he looked down at his pocket and sighed. Every commodity Xiao Ming wants to buy has its price and expectation value. Xiao Ming can only use limited funds to buy a series of items that can make the total expectation value reach the maximum.
###Input format:
An integer t in the first line indicates that there are t sets of test data (T < = 50).
Next, t group test data:
The first line contains two integers n and M. n represents how much money Xiao Ming has and M represents how many items he has (1 < = m < = 100).
The second line contains M integers, representing the price of each item.
The third line contains M integers, indicating Xiao Ming's expectation of each item.
Among them, the value range of money n in Xiaoming's pocket, the price of each item and the expected value of each item are (0, 3000).
###Output format:
Each group of samples has one line, and outputs the sum of the maximum expected values. Assuming that the maximum expected value of group I sample is e, the output format is "case # I: e"
###Input example:
```in
four
10 5
2 3 7 7 3
4 3 5 6 4
10 8
5 6 4 2 3 7 1 8
5 3 5 3 5 7 5 7
20 7
10 15 4 5 6 8 5
15 14 9 2 2 6 7
10 3
7 4 5
16 7 10
```
###Output example:
```out
Case #1: 11
Case #2: 18
Case #3: 31
Case #4: 17
```







answer:If there is no answer, please comment