Submission #744379

#TimeUsernameProblemLanguageResultExecution timeMemory
744379Dan4LifeDetecting Molecules (IOI16_molecules)C++17
100 / 100
56 ms5196 KiB
#include "molecules.h"
#include <algorithm>
using namespace std;
array<int64_t,2> v[200010];

vector<int> find_subset(int L, int R, vector<int> w) {
    int n = w.size();
    for(int i = 0; i < n; i++) v[i]={w[i],i};
    sort(v,v+n); vector<int> A; 
    int64_t s = 0;
    for(int i = 0, j = 0; i < n; s-=v[i++][0]){
        while(j<=n and s<L) s+=v[j++][0];
        if(L<=s and s<=R and j<=n){
            for(int k = i; k < j; k++)
                A.push_back((int)v[k][1]);
            break;
        }
    }
    return A;
}
#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...