# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413941 | Dakto | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 204 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>
#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int,int>> v;
for(int i=0; i<w.size(); i++){
v.push_back({w[i],i});
}
sort(v.begin(),v.end());
auto f=v[0];
v.erase(v.begin());
vector<int> res;
int s=0;
while(!v.empty() && s<l){
if(s+f.first>=l){
s+=f.first;
res.push_back(f.second);
break;
}
s+=end(v)->first;
res.push_back(v.back().second);
v.erase(v.end()-1);
if(s>=l) break;
if(s+f.first>=l){
s+=f.first;
res.push_back(f.second);
break;
}
}
if(s>=l && s<=u) return res;
else return vector<int>(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |