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;
typedef long long int ll;
typedef pair<ll,int> pll;
vector<pll> nw;
int n;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
n=(int)w.size();
for(int i=0;i<n;i++) nw.push_back({(ll)w[i],i});
sort(nw.begin(),nw.end());
ll mn=0,mx=0;
for(int k=0;k<n;k++){
mn+=nw[k].first; mx+=nw[n-k-1].first;
if((ll)u<mn) return vector<int>(0);
if(mx<(ll)l) continue;
if((ll)l<=mn&&mn<=(ll)u){
vector<int> re;
for(int i=0;i<=k;i++) re.push_back(nw[i].second);
return re;
}
if((ll)l<=mx&&mx<=(ll)u){
vector<int> re;
for(int i=k;i>=0;i--) re.push_back(nw[n-i-1].second);
return re;
}
int s=0,e=k,c=mn;
while(1){
if((ll)l<=c&&c<=(ll)u){
vector<int> re;
for(int i=s;i<=e;i++) re.push_back(nw[i].second);
return re;
}
if(c<(ll)l) c+=nw[++e].first;
else if(c>(ll)u) c-=nw[s++].first;
}
}
return vector<int>(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |