# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
763890 | ind1v | Detecting Molecules (IOI16_molecules) | C++11 | 1 ms | 340 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>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&w](int &i, int &j) -> bool {
return w[i] < w[j];
});
deque<int> dq;
long long sum = 0;
for (int i = 0; i < n; i++) {
if (sum + w[ord[i]] < l) {
dq.emplace_back(ord[i]);
sum += w[ord[i]];
} else if (l <= sum + w[ord[i]] && sum + w[ord[i]] <= u) {
dq.emplace_back(ord[i]);
sum += w[ord[i]];
vector<int> ans(dq.begin(), dq.end());
return ans;
} else {
if (dq.empty()) {
return vector<int>(0);
} else {
sum -= w[dq.front()];
dq.pop_front();
sum += w[ord[i]];
dq.push_back(ord[i]);
if (l <= sum && sum <= u) {
vector<int> ans(dq.begin(), dq.end());
return ans;
}
}
}
}
}
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... |