# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81770 | AngelKnows | 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"
using namespace std;
const int inf=0x3f3f3f3f;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(w.begin(),w.end());
vector<int> ans;
int L=l,R=u;
if (L<=w[0]&&w[0]<=R) {
ans.push_back(w[0]);
return ans;
} else if (w[0]>R) {
return vector<int>(0);
} else if (w[0]<L) {
int t=w.back();
if (L<=t&&t<=R) {
ans.push_back(t);
return ans;
} else if (t<L) {
long long sum=0;
for (int i=0;i<w.size();i++) {
sum+=w[i];
ans.push_back(w[i]);
if (L<=sum&&sum<=R) {
return ans;
}
}
return vector<int>(0);
}
}
}