-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path1227-Boiled_Eggs.cpp
More file actions
59 lines (45 loc) · 840 Bytes
/
Copy path1227-Boiled_Eggs.cpp
File metadata and controls
59 lines (45 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
#define ll long long
#define MAX 100100
using namespace std;
ll arr[100100];
vector <pair <ll, ll> > v;
int main()
{
#ifndef ONLINE_JUDGE
freopen("/home/sameer/Documents/sameer/input.sam", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
ll i, j, k, n, m, t, cont, a, b, p, q;
cin >> t;
ll cases = t;
while (t--) {
cin >> n >> p >> q;
for (i = 0; i < n; i++)
cin >> arr[i];
sort(arr, arr + n);
ll sum = 0;
ll cnt = 0;
ll ans = 999;
for (i = 0; i < n; i++) {
sum += arr[i];
cnt++;
if (sum > q and cnt == p) {
ans = cnt - 1;
break;
}
if (sum > q) {
ans = cnt - 1;
break;
}
if (sum <= q and cnt == p) {
ans = cnt;
break;
}
}
if (ans == 999)
ans = n;
cout << "Case " << cases - t << ": " << ans << endl;
}
return 0;
}