-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVersaForSanta.cpp
More file actions
executable file
·49 lines (41 loc) · 1.12 KB
/
VersaForSanta.cpp
File metadata and controls
executable file
·49 lines (41 loc) · 1.12 KB
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
// g++ VersaForSanta.cpp -o VersaForSanta && ./VersaForSanta
/*
*/
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
int main(){
int t;
cin >> t;
while(t--){
ull s, n;
cin >> n >> s;
vector<ull> arr(n+1);
for(int i = 1; i <= n; i++) cin >> arr[i];
int CM = 0;
int CI = 0;
int i;
for(i = 0; i < n; i++){
if(arr[i] > CM){
if(CM > s) break;
// cout << "came in if" << endl;
s -= CM;
CM = arr[i];
CI = i;
// deb2(CI, CM);
// deb(s);
}
else{
// cout << "came in else" << endl;
if(arr[i] > s) break;
s -= arr[i];
}
}
// deb(i);
if(arr[i] == CM) CI = 0;
else if(CM <= s) CI = 0;
cout << CI << endl;
}
}