# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781337 | devariaota | 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 "molecules.h"
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int sz=0;
vector<pair<int, int>> a;
for(int p : w) a.push_back({p, sz++});
sort(a.begin(), a.end());
int sum=0;
int L=0, R=0;
while(L<sz) {
while(R<sz && sum<l) sum+=a[R++].first;
if(l<=sum && sum<=u) {
vector<int> ans;
for(int i=L; i<R; i++) ans.push_back(i);
return ans;
}
sum-=a[L++].first;
if(l<=sum && sum<=u) {
vector<int> ans;
for(int i=L; i<R; i++) ans.push_back(i);
return ans;
}
}
}