General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
98493657 Contestant:
ken_kaneki_124
1447C - 29 GNU C++14 Time limit exceeded on pretest 3 2000 ms 3112 KB 2020-11-15 20:04:59 2020-11-15 20:04:59
 
 
→ Source
#include <bits/stdc++.h>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"
#define llu unsigned long long int
#define ll long long int
#define fore(i, n) for(auto i = 0; i < n ; i++)
#define forb(i, n) for(auto i = n-1; i >= 0; i++)
#define pair(k, z) pair<k, z>
#define vec(k) vector<k>
#define map(k, z) map<k, z> 
#define set(k) set<k>
#define gcd(a, b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define ins insert
#define pp pair<int,int>
using namespace std;
bool cmp(const pp &l,const pp &r) {
    return l.first < r.first;
}
int main()
{
    fastio;
    int t;
    cin >> t;
    
    while(t--)
    {
        ll n, m, x, ans = 0, c = 0, f = 1, min = 1000, k, sum = 0;
        cin >> n >> k;
        vector<pair<ll, ll>> s;
        vector<ll> v;
        for(ll i = 0; i < n; i++)
        {
            cin >> x;
            s.pb({x, i});
        }
        sort(s.begin(), s.end(), cmp);
        while(true)
        {
            if(s.size() == 0)
                break;
            pair<ll, ll> p = {(k+1)/2 - ans, 0};
            auto it = lower_bound(s.begin(), s.end(), p);
            if(it -> first + ans <= k && it != s.end())
            {
                ans = ans + it -> first;
                v.pb(it -> second);
                break;
            }
            else
            {
                it = s.begin();
                ans = ans + it -> first;
                if(ans > k)
                {
                    f = 0;
                    break;
                }
                v.pb(it -> second);
                s.erase(it);
            }
        }
        if(v.size() == 0 || f == 0)
            cout << "-1\n";
        else
        {
            if(ans < (k+1)/2)
                cout << "-1\n";
            else
            {
                cout << v.size() << "\n";
                for(auto y : v)
                    cout << y+1 << " ";
                cout << "\n";
            }
        }
    }
    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details