# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
350655 | spike1236 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
veci find_subset(ll l, ll r, veci w) {
int n = sz(w);
vector <pair <ll, int> > a;
for(int i = 0; i < n; ++i)
a.pb(mp(w[i], i));
sort(all(a));
for(int i = 0; i < n; ++i) {
ll sum = a[i].f, mn = a[i].f, mx = a[i].f;
if(l <= sum && sum <= r)
return {a[i].s};
for(int j = i + 1; j < n; ++j) {
sum += a[j].f;
mn = min(mn, a[j].f);
mx = max(mx, a[j].f);
if(sum > r) break;
if(r - l < mx - mn) break;
if(sum < l) continue;
veci res;
for(int k = i; k <= j; ++k)
res.pb(a[k].s);
sort(all(res));
return res;
}
}
return {};
}