# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1217077 | moondarkside | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 0 KiB |
vector<int> find_subset( int l, int u, vector<int> w ) {
sort(w.begin(),w.end());
if(w[0]>u){
return vector<int>();
}
int weight=0;
std::queue<int> Solution;
for(int i=0;i<w.size();i++){
if(weight>=l && weight<=u){
vector<int> Sol;
while(!Solution.empty()){
Sol.push_back(Solution.front());
Solution.pop();
}
return Sol;
}
if(weight<l){
Solution.push(i);
weight+=w[i];
}
else{
weight-=w[Solution.front()];
Solution.pop();
}
}
return vector<int>();
}