# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240239 | Amy313 | 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<int, int> >M;
vector<int> A;
int s, n = w.size(), c;
for(int i=0; i<w.size(); i++)
{
M.push_back(make_pair(W[i], i+1));
}
sort(M.begin(), M.end());
A.clear();
if(M[0].first>u)
{
return A;
}
for(int i=n-1; i>=0; i--)
{
s = M[i].first;
c =0;
A.push_back(M[i].second);
if(s<l)
{
for(int j=0; j<w.size(); j++)
{
s+=M[j].first;
A.push_back(M[j].second);
if(s>=l and s<=u)
{
c = 1;
break;
}
else
{
if(s>u)
{
A.erase(A.size()-1);
break;
}
}
}
if(c==1)
{
break;
}
}
else
{
if(s<=u)
{
break;
}
}
}
return A;
}