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;
#define int long long
vector<signed> sb;
std::vector<signed> find_subset(signed l, signed u, std::vector<signed> W) {
int n = W.size();
vector<pair<int, int>> w(n);
for (int i = 0; i < n; i++) {
w[i] = make_pair(W[i], i);
}
sort(w.begin(), w.end());
int sum = 0;
int R = -1;
while (R+1 < n && sum + w[R+1].first <= u) {
sum += w[++R].first;
sb.push_back(w[R].second);
}
if (l <= sum) return sb;
int L = n;
while (min(R, L-1) >= 0 && sum - w[R].first + w[L-1].first <= u) {
sum += w[--L].first - w[R--].first;
sb.pop_back();
}
for (int i = n-1; i >= L; i--) {
sb.push_back(w[i].second);
}
if (sum < l || u < sum) sb.clear();
return sb;
}
# | 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... |