# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198774 | AaronNaidu | 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;
long long n, l, u, sum;
int lp, rp;
pair<long long, long long> weights[200005];
int find_subset(int l, int u, int* w, int n, int* result) {
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
for (int i = 0; i < n; i++)
{
weights[i].first = w[i];
weights[i].second = i;
}
sort(weights, weights + n);
lp = rp = sum = 0;
while(true) {
if(sum < l) {
if(rp == n) {
break;
}
sum += weights[rp].first;
rp++;
}
else if(sum > u) {
sum -= weights[lp].first;
lp++;
}
else {