# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118938 | adaawf | Detecting Molecules (IOI16_molecules) | C++17 | 47 ms | 7868 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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long int c[200005];
vector<int> find_subset(int l, int u, vector<int> a) {
vector<pair<int, int>> v;
v.push_back({0, 0});
for (int i = 0; i < a.size(); i++) {
v.push_back({a[i], i});
}
sort(v.begin(), v.end());
int n = v.size() - 1;
for (int i = 1; i <= n; i++) c[i] = c[i - 1] + v[i].first;
for (int i = 1; i <= n; i++) {
if (c[i] > u) continue;
if (c[n] - c[n - i] < l) continue;
long long int h = c[i];
vector<int> vv;
for (int j = 1; j <= i; j++) vv.push_back(v[j].second);
if (h >= l && h <= u) return vv;
for (int j = i - 1; j >= 0; j--) {
h -= a[vv[j]];
h += v[n - i + j + 1].first;
vv[j] = v[n - i + j + 1].second;
if (h >= l && h <= u) return vv;
}
}
vector<int> vv;
return vv;
}
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... |