| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1324718 | kasamchi | Detecting Molecules (IOI16_molecules) | C++20 | 35 ms | 4112 KiB |
#include "molecules.h"
#include <bits/stdc++.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(make_pair(w[i], i));
}
sort(v.begin(), v.end());
if (v[0].first > u) {
return vector<int>();
} else {
int ll = 0, rr = 0;
long long sum = 0;
while (rr < n && sum < l) {
sum += v[rr].first, rr++;
}
if (sum < l) {
return vector<int>();
} else if (sum <= u) {
vector<int> ans;
for (int i = 0; i < rr; i++) {
ans.push_back(v[i].second);
}
return ans;
} else {
sum -= v[rr - 1].first, rr--;
int ll = 0;
while (rr < n && sum < l) {
sum -= v[ll].first, ll++;
sum += v[rr].first, rr++;
}
if (sum < l) {
return vector<int>();
} else {
vector<int> ans;
for (int i = ll; i < rr; i++) {
ans.push_back(v[i].second);
}
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... | ||||
