# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710043 | Baytoro | 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>
//#include "grader.cpp"
using namespace std;
#define int long long
vector<pair<int,int>> vec;
vector<int> get(int l, int r){
vector<int> ans;
for(int i=l;i<=r;i++) ans.push_back(vec[i].second);
sort(ans.begin(),ans.end());
return ans;
}
vector<int> find_subset(int v, int u, vector<int> w) {
int n=w.size();
int sum=0;
for(int i=0;i<n;i++)
vec.push_back({w[i],i});
sort(vec.begin(),vec.end());
int l=0;
for(int r=0;r<n;r++){
sum+=vec[r].first;
if(sum<v) continue;
if(v<=sum && sum<=u){
return get(l,r);
}
else{
while(sum>u){
sum-=vec[l].first;
l++;
}
if(v<=sum && sum<=u){
return get(l,r);
}
}
}
return {};
}