- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define endl "\n"
- #define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ALL(x) x.begin(),x.end()
- #define SORT(x) sort(ALL(x))
- #define FOR(a,b,c) for(ll (a)= (b);(a)<(c);++(a))
- #define REP(a,b) FOR(a,0,b)
- #define mp make_pair
- #define pb push_back
- #define pll pair<ll,ll>
- #define pii pair<int,int>
- #define vl vector<ll>
- #define vi vector<int>
- #define f first
- #define s second
- #define yy cout<<"YES"<<endl;return
- #define nn cout<<"NO"<<endl;return
- #define minus1 cout<<-1<<endl;return
- #define rd(a,x) REP(i,x)cin >> a[i]
- int ttt = 1, case_ = 0;
- ll n, m, k;
- string S;
- template <class myType>
- void print_arr(myType &arr, ll L, string sep){
- REP(i,L){ cout << arr[i] << (i < L-1 ? sep : "\n"); }
- return; }
- /*
- Solve the smallest problem I can at any time
- I can add index k to my pile when at least (k - 1)/2 problems have been solved
- When 0 problems solved, indices 0 and 1
- When 1 problem solved, indices 2 and 3
- When 2 problems solved, indices 4 and 5
- Etc
- */
- void solve() {
- cin >> n >> k;
- vl a(n);
- rd(a, n);
- priority_queue<pll, vector<pll>, greater<pll>> q;
- ll solved = 0, t = 0;
- vl ans;
- vector<bool> used(n, 0);
- while (1) {
- // add all problems I am now allowed to solve to the priority queue
- vl targ = {2*solved, 2*solved + 1};
- for(ll j: targ) {
- if (j >= n) continue;
- if (used[j]) continue;
- used[j] = 1;
- q.push(mp(a[j], j+1));
- }
- // if there are no problems in the PQ, I can't do anything, so break
- if (q.empty()) {
- break;
- }
- // take the shortest problem from the PQ. If it's too long to solve, break
- if (q.top().f + t <= k) {
- t += q.top().f;
- solved++;
- ans.pb(q.top().s);
- q.pop();
- }
- else {
- break;
- }
- }
- cout << solved << endl;
- if (solved) print_arr(ans, solved, " ");
- else cout << endl;
- return;
- }
- int main() {
- quick;
- cin >> ttt;
- while (ttt--) solve();
- return 0;
- }