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"
#define fi first
#define se second
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<pair<int, int>> s;
for (int i = 0; i < n; i++) {
s.push_back(make_pair(w[i], i+1));
}
sort(s.begin(), s.end());
vector<int> sp (n, 0);
vector<int> ss (n, 0);
sp[0] = s[0].fi;
ss[n-1] = s[n-1].fi;
for (int i = 1; i < n; i++) {
sp[i] = sp[i-1]+s[i].fi;
ss[n-1-i] = ss[n-i]+s[n-1-i].fi;
}
for (int i = 0; i < n; i++) {
if (sp[i] <= u && ss[n-1-i] >= l) {
vector<int> v;
int sum = 0;
for (int j = 0; j <= i; j++) {
v.push_back(s[j].se);
sum += s[j].fi;
}
for (int j = 0; j <= i; j++) {
if (sum < l) {
sum -= s[j].fi;
sum += s[n-1-j].fi;
v[j] = s[n-1-j].se;
}
}
return v;
}
}
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... |