# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
469906 | IvnF | 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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int>ans;
vector<pair<int, int>>v;
for(int i=0;i<w.size();++i){
v.pb({w[i], i});
}
sort(v.begin(), v.end());
long long n=w.size(), kiri=0, sums=0, i=0;
for(;i<n;++i){
int berat=v[i].first;
sums+=berat
while(sums > u) sums-=v[kiri++].first;
if(sums>=l && sums<=u){
for(long long j=kiri;j<=i;++j) ans.push_back(v[j].second);
return ans;
}
}
return ans;
}