2672Xiaoqian’s Invitation

2672   Xiaoqian’s Invitation

题目描述

Xiaoqian, member of our ACM team, wanted to invite us to her home and enjoy a dinner. Her mum gave her M Yuan. Now it’s time to order dishes. There are N people here. Each has a chance to order one dish, Xiaoqian first, then everyone else (until the last one or no more money to order any dish). No dish could be ordered twice. Now Xiaoqian wants to minimize the fee and we want to maximize the fee (not larger than M). Can you help Xiaoqian to choose the first dish so that the possible maximum fee is minimized?

输入格式:

First line contains only one integer C, the number of test case. For each test case, first line contains three integers N, M and D. D is the number of dishes offered. Then D lines followed, prices of each dish, none of them larger than 100. (0<N≤200, 0<M≤10000, 0≤D≤100)

输出格式:

Output one integer per line for each test case: the minimum maximum fee.

输入样例 复制
1
5 10 6
3
2
2
2
2
2
输出样例 复制
9

说明

1
7
通过提交
时空限制1000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度