# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997672 | AtinaR | 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;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
vector<pair<long long,long long> > v;
for(long long i=0; i<w.size(); i++)
{
v.push_back({w[i],i});
}
sort(v.begin(),v.end());
long long i=0,j=0;
long long sum=0;
long long n=w.size();
while(j<n)
{
while(j<n && sum<l)
{
sum+=v[j].first;
j++;
}
if(sum>=l && sum<=u)
{
vector<long long> res;
for(long long k=i; k<j; k++)
{
res.push_back(v[k].second);
}
sort(res.begin(),res.end());
return res;
}
sum-=v[i].first;
i++;
}
return {};
}