# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1222323 | vidux | Detecting Molecules (IOI16_molecules) | C++17 | 36 ms | 5192 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ALL(x) (x.begin()), (x.end())
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_ARR(x) cerr << #x << ": "; for (auto &y : x) cout << y << " "; cout << endl;
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
std::vector<int> find_subset(int low, int high, std::vector<int> w) {
int n = SZ(w);
vector<pll> a(n);
for (int i = 0; i < n; i++) a[i] = {w[i], i};
sort(ALL(a));
int l = 0, r = 1;
ll sum = a[0].fi;
while (l < n) {
if (sum < low) {
if (r == n) break;
sum += a[r++].fi;
}
else if (sum > high) {
sum -= a[l++].fi;
}
if (sum >= low && sum <= high) {
vi ans(r-l);
for (int i = l; i < r; i++) ans[i-l] = a[i].se;
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... |