# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
956140 | manishjha91 | Detecting Molecules (IOI16_molecules) | C++17 | 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.
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
std::vector<pair<int,int>> curr;
for(int i=0; i<w.size(); i++)
{
curr.push_back({w[i],i});
}
sort(curr.begin(),curr.end());
long long sum = 0;
bool found = 0;
int low = 0;
int hi = 0;
for(; hi<curr.size(); hi++)
{
sum+=curr[hi].first;
while(sum>u)
{
sum-=curr[low++].first;
}
if(sum>=l)
{
found = 1;
break;
}
}
if(!found)
return std::vector<int>(0);
std::vector<int> res;
for(int i=low; i<=hi; i++)
{
res.push_back(curr[i].second);
}
sort(res.begin(),res.end());
return res;
}