-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
42 lines (42 loc) · 796 Bytes
/
A.cpp
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
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve() {
int n;
long long W;
cin >> n >> W;
vector <long long> a (n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
long long low = (W + 1) / 2;
long long sum = 0;
vector <int> idx;
for(int i = 0; i < n; i++) {
if(a[i] > W) continue;
if(low <= a[i]) {
cout << 1 << endl;
cout << i + 1 << endl;
return ;
}
if(sum + a[i] <= W) {
sum += a[i];
idx.push_back(i + 1);
}
}
if(low <= sum && sum <= W) {
cout << idx.size() << endl;
for(auto i : idx) cout << i << " ";
cout << endl;
} else {
cout << -1 << endl;
}
}
int main() {
ios_base :: sync_with_stdio (false);
cin.tie(0);
int t;
cin >> t;
while(t--) solve();
return 0;
}