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;
vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> ans;
vector<pair<int, int>> arr(w.size());
for (size_t i = 0; i < w.size(); i++) {
arr[i] = {w[i], i + 1};
}
sort(begin(arr), end(arr));
size_t R = 0;
long long sum = arr[0].first;
for (size_t L = 0; L < w.size(); L++) {
if (R < L) {
R = L;
sum = arr[R].first;
}
while (R + 1 < w.size() && sum + arr[R + 1].first <= u) sum += arr[++R].first;
if (sum >= l && sum <= u) {
for (size_t s = L; s <= R; s++) ans.push_back(arr[s].second);
break;
}
}
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... |