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"
#define ll long long
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<int> ind(n);
for (int i = 0; i < n; i++)
ind[i] = i;
sort(ind.begin(), ind.end(), [&](int x, int y){
return (w[x] < w[y]);
});
vector<int> answer;
ll pref_sum = 0;
for (int i = 0; i < n; i++){
ll sum = pref_sum;
if (sum > u)
break;
if (sum >= l){
for (int h = 0; h < i; h++)
answer.push_back(ind[h]);
return answer;
}
for (int j = n-1; j >= i; j--){
sum += w[ind[j]];
if (sum > u)
break;
if (sum >= l){
for (int h = 0; h < i; h++)
answer.push_back(ind[h]);
for (int h = j; h < n; h++)
answer.push_back(ind[h]);
return answer;
}
}
pref_sum += w[ind[i]];
}
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... |