# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963188 | maxFedorchuk | 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.
#include <bits/stdc++.h>
using namespace std;
#include "molecules.h"
vector<int> find_subset(const long long l,const long long u,const vector<long long> w)
{
vector < pair < long long ,long long > > mas;
vector < int > ans;
for(long long i=0;i<w.size();i++)
{
mas.push_back({w[i],i});
}
sort(mas.begin(),mas.end());
for(long long sum=0,ru=0,lu=0;ru<w.size();ru++)
{
sum+=mas[ru].first;
while(sum>u)
{
sum-=mas[lu].first;
lu++;
}
if(sum>=l)
{
for(long long j=lu;j<=ru;j++)
{
ans.push_back(mas[j].second);
}
break;
}
}
return ans;
}