# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
716957 | Desh03 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 212 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;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) v.push_back({w[i], i});
sort(v.begin(), v.end());
int sum = 0;
vector<int> ans;
for (int i = 0; i < n; i++) {
if (i < n - 1) {
if (sum + v[i].first < l && sum + v[i].first + v[i + 1].first > u) {
continue;
} else if (sum + v[i].first > u) {
if (ans.empty()) return ans;
else {
i = ans.back();
sum = 0;
ans.clear();
}
} else if (sum + v[i].first >= l && sum + v[i].first <= u) {
ans.push_back(v[i].second);
return ans;
} else {
ans.push_back(v[i].second);
sum += v[i].first;
}
} else {
if (sum + v[i].first >= l && sum + v[i].first <= u) {
ans.push_back(v[i].second);
return ans;
} else {
if (ans.empty()) return ans;
else {
i = ans.back();
sum = 0;
ans.clear();
}
}
}
}
}
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... |