| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1304297 | Ekber_Ekber | Detecting Molecules (IOI16_molecules) | C++20 | 51 ms | 8728 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
vector<int32_t> find_subset(int32_t l, int32_t r, vector<int32_t> v) {
int n = v.size();
vector <pair<int, int>> v1;
for (int i = 0; i < n; i++) {
v1.pb({v[i], i});
}
sort(all(v1));
vector <int> id;
for (int i = 0; i < n; i++) id.pb(v1[i].ss);
sort(all(v));
vector <int> pr(all(v));
for (int i = 1; i < n; i++) pr[i] += pr[i-1];
for (int i = 0; i < n; i++) {
// cout << endl << i << ": ";
int a = i, b = n-1, ans=-1;
while (a <= b) {
int m = (a + b) / 2;
int s = pr[m] - (i == 0 ? 0 : pr[i-1]);
if (v[m] - v[i] > r - l) b = m - 1;
if (s <= r) ans = m, a = m + 1;
else b = m - 1;
}
if (ans == -1) continue;
if (pr[ans] - (i == 0 ? 0 : pr[i-1]) >= l) {
vector <int32_t> res;
for (int j = i; j <= ans; j++) {
res.pb(id[j]);
}
sort(all(res));
return res;
}
}
vector <int32_t> null;
return null;
}
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... | ||||
