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;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans={};
int n=w.size(),sum=0,m=0,k,p,x=0;
for(int i=0;i<n;i++) sum+=w[i];
if(sum<l) return ans;
sort(w.begin(),w.end());
sum=0;
for(int i=0;i<n;i++){
if(sum+w[i]>u) break;
sum+=w[i];
m=i+1;
}
if(m==0) return {};
k=n-1;
p=0;
while(sum<l){
if(k<m || p==m) break;
x++;
sum+=w[k];
sum-=w[p];
k--;
p++;
}
if(sum<l) return {};
for(int i=x;i<m;i++) ans.push_back(w[i]);
for(int i=n-1;i>=n-x;i--) ans.push_back(w[i]);
return ans;
}
# | 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... |