# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444652 | Hanksburger | Detecting Molecules (IOI16_molecules) | C++17 | 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;
pair<long long, long long> a[200000];
int[] find_subset(int l, int u, int[] w)
{
long long n=sizeof(w)/sizeof(w[0]), r=u, index=0, sum=0;
for (long long i=0; i<n; i++)
{
a[i].first=w[i];
a[i].second=i;
}
sort(a, a+n);
for (long long i=0; i<n; i++)
{
while (1)
{
if (l<=sum && sum<=r)
{
int ans[index-i];
for (long long j=i; j<index; j++)
ans[j-i]=a[j].second;
return ans;
}
if (index<n && sum<=r)
{
sum+=a[index].first;
index++;
}
else
break;
}
sum-=a[i].first;
}
int ans[0];
return ans;
}