# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916101 | Aiperiii | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n=w.size();
vector <pair <int,int> > v;
for(int i=0;i<n;i++){
v.pb({w[i],i});
}
sort(all(v));
int sum=0,p1=0;
vector <int> ans;
for(int i=0;i<n;i++){
sum+=v[i].ff;
while(sum>u){
sum-=v[p1].ff;
p1++;
}
if(sum>=l && sum<=u){
for(int j=p1;j<=i;j++)ans.pb(v[j].ss);
break;
}
}
return ans;
}