Code: Select all

```
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int t;
cin >> t;
for (int tt = 0; tt < t; tt++){
int n, p, q;
cin >> n >> p >> q;
int a[31];
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a, a + n);
int mx;
if (p < q)
mx = p;
else
mx = q;
int sum = 0;
for (int i = 1; i <= mx; i++){
sum += a[i];
if (sum >= q)
if (i - 1 < mx)
mx = i - 1;
}
cout << "Case " << tt + 1 << ": " << mx << endl;
}
}
```