# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397133 | ak2006 | 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 ll long long
#define vi vector<int>
#define vvi vector<vi>
int [] find_subset(int l,int u,int [] w)
{
int n = sizeof(w)/sizeof(w[0]);
vvi a(n,vi(2));
for (int i = 0;i<n;i++)a[i][0] = w[i],a[i][1] = i;
ll sum = a[0][0],l = 0,r = 1;
while (r <= n){
if (sum >= mn && sum <= mx)break;
if (sum > mx){sum -= a[l][0];l++;}
else {if (r == n)break;sum += a[r][0];r++;}
if (sum >= mn && sum <= mx)break;
}
if (!(sum >= mn && sum <= mx))return [];
int ret[r - l];
for (int i = l;i<r;i++)ret[i - l] = a[i][1];
}