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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define pb push_back
#define pi pair<int,int>
#define w first
#define ind second
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pi> weights(n);
for(int i =0; i<n ;i++){
weights[i] = {w[i], i};
}
sort(weights.begin(), weights.end());
vector<int> ans;
int cursum = 0;
for(int i =n-1; i>=0; i++){
if(cursum + weights[i].w < l){
cursum += weights[i].w;
ans.pb(weights[i].ind);
}
else if( cursum + weights[i].w >= l and cursum + weights[i].w <=u){
ans.pb(weights[i].ind);
sort(ans.begin(), ans.end());
//for(int a : ans)cout << a <<",";
//cout <<endl;
return ans;
}
}
return vector<int>();
}
/***************/
# | 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... |