Responsive image

问题 1520 --This is not what I want maximum

1520: This is not what I want maximum

时间限制: 1 Sec  内存限制: 128 MB
提交: 2  解决: 2
[提交][状态][讨论版][命题人:]

题目描述

One day, Lucy went to the supermarket to buy a lot of apples, a variety of prices of fruit on display shelves, but she's only a shopping bag for apples, and she did not intend to use other shopping bag.
Today she doesn't want to buy the maximum value to fill the shopping bag of apples,but the K-th maximum value of the apples. NOTICE that, you should considerate two ways that get the same value of apples are the same. That means, it will be a strictly decreasing sequence from the 1st maximum, 2nd maximum .. to the K-th maximum.If the total number of different values is less than K, just ouput 0.

输入描述

The first line contain a integer T , the number of cases.
Followed by T cases , each case three lines , the first line contain two integer N , V, K(N <= 100 , V <= 1000 , K <= 30)representing the number of apples and the volume of her bag and the K we need. And the second line contain N integers representing the value of each apple. The third line contain N integers representing the volume of each apple.

输出描述

One integer per line representing the K-th maximum of the total value (this number will be less than 231).

样例输入

3
5 10 2
1 2 3 4 5
5 4 3 2 1
5 10 12
1 2 3 4 5
5 4 3 2 1
5 10 16
1 2 3 4 5
5 4 3 2 1

样例输出

12
2
0

提示

有多组数据,每组给出一个T。

来源

[提交][状态]
ACM算法攻关部