# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963184 | 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 int l,const int u,const vector<int> w)
{
vector < pair < int ,int > > mas;
vector < int > ans;
for(int i=0;i<w.size();i++)
{
mas.push_back({w[i],i+1});
}
sort(mas.begin(),mas.end());
vector < int > ans;
for(int 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(int j=lu;j<=ru;j++)
{
ans.push_back(mas[j].second);
}
break;
}
}
return ans;
}