| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1288785 | muhammad-ahmad | Detecting Molecules (IOI16_molecules) | C++20 | 3 ms | 844 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define ll long long
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> X;
for (int i = 0; i < n; i++){
X.push_back({w[i], i});
}
sort(X.begin(), X.end());
int a[n + 1], idx[n + 1];
for (int i = 0; i < n; i++){
a[i + 1] = X[i].first;
idx[i + 1] = X[i].second;
}
ll pref[n + 2] = {}, suf[n + 2] = {};
for (int i = 1; i <= n; i++){
pref[i] = a[i] + pref[i - 1];
}
for (int i = n; i >= 1; i--){
suf[i] = suf[i + 1] + a[i];
}
suf[0] = 2 * u;
int R = 0;
for (int L = 0; L <= n; L++){
while (R <= n && (pref[L] + suf[R]) > u) R++;
// cout << L << ' ' << R << endl;
if (pref[L] + suf[R] >= l && pref[L] + suf[R] <= u && R > L){
vector<int> ans;
for (int i = 1; i <= L; i++) ans.push_back(idx[i]);
for (int i = R; i <= n; i++) ans.push_back(idx[i]);
return ans;
}
}
return {};
}
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... | ||||
