Submission #867546

#TimeUsernameProblemLanguageResultExecution timeMemory
867546StefanL2005Detecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms432 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

vector<int> find_subset(int L, int R, vector<int> v)
{
    int n = v.size();
    vector<pair<int,int>> w(n);

    for (int i = 0; i < n; i++)
        w[i] = make_pair(v[i], i);
    sort(w.begin(), w.end());

    deque<int> Q;
    vector<int> result;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        if(L <= sum && sum <= R)
            break;
        
        sum += w[i].first;
        Q.push_back(w[i].second);

        while(sum > R && !Q.empty())
        {
            sum-= w[Q.front()].first;
            Q.pop_front();
        }
    }

    while(!Q.empty())
    {
        result.push_back(Q.front());
        Q.pop_front();       
    }

    
    return result;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...