# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012993 | aufan | Detecting Molecules (IOI16_molecules) | C++17 | 35 ms | 6340 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"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
long long sum = 0;
vector<pair<int, int>> v;
int n = w.size();
for (int i = 0; i < n; i++) v.push_back(make_pair(w[i], i));
sort(v.begin(), v.end());
int idx;
for (int i = 0; i < n; i++) {
sum += v[i].first;
if (sum >= l) {
idx = i;
break;
}
}
vector<int> ans;
if (sum < l) {
return ans;
}
if (sum <= u) {
for (int i = 0; i <= idx; i++) {
ans.push_back(v[i].second);
}
return ans;
} else {
sum -= v[idx].first;
int p = n - 1;
for (int i = idx - 1; i >= 0; i--) {
sum -= v[i].first;
sum += v[p].first;
if (sum >= l) {
for (int j = 0; j < i; j++) {
ans.push_back(v[j].second);
}
for (int j = p; j < n; j++) {
ans.push_back(v[j].second);
}
return ans;
}
p--;
}
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... |