# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1132206 | lopkus | Detecting Molecules (IOI16_molecules) | C++20 | 40 ms | 4132 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> a) {
int n = (int) a.size();
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
v.push_back({a[i], i});
}
sort(v.begin(), v.end());
long long sum = v[0].first;
int i = 0, j = 0;
while (i < n && j < n) {
if (sum >= l && sum <= u) {
break;
}
if (sum <= u && j < n - 1) {
if (j + 1 == n) {
break;
}
j++;
sum += v[j].first;
} else {
sum -= v[i].first;
i++;
}
}
vector<int> ans;
if (sum >= l && sum <= u) {
for (int h = i; h <= j; h++) {
ans.push_back(v[h].second);
}
}
sort(ans.begin(), ans.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... |