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 <vector>
#include <algorithm>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = (int)w.size();
vector<pair<int, int>> a;
for (int i = 0; i < n; i++) {
a.push_back({w[i], i});
}
sort(a.begin(), a.end());
int left = 0, right = 0;
int cur_sum = a[0].first;
bool poss = false;
while (right < n) {
while (cur_sum < l) {
right++;
cur_sum += a[right].first;
}
while (cur_sum > u) {
cur_sum -= a[left].first;
left++;
if (right < left) {
right = left;
cur_sum = a[left].first;
}
}
if (cur_sum >= l && cur_sum <= u) {
poss = true;
break;
}
}
vector<int> answer(0);
if (poss) {
for (int i = left; i <= right; i++) {
answer.push_back(a[i].second);
}
}
return answer;
}
# | 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... |