# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
706764 | Yell0 | 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;
typedef pair<int,int> pii;
typedef long long ll;
int find_subset(int l,int u,vector<int> w,int n,vector<int>& result) {
vector<pii> a;
for(int i=0;i<n;++i) a.push_back({w[i],i});
sort(a.begin(),a.end());
int i=0,j=0;
ll sum=0;
for(;i<n;++i) {
sum+=a[i].first;
if(sum>=l) break;
}
if(sum<l) return 0;
for(;j<=i;++j) {
sum-=a[j].first;
if(sum<=u) break;
}
if(sum>u) return 0;
for(int x=0;x<=i-j;++x) result[x]=a[x+j].second;
return 0;
}