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;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector <int> ans;
vector <pair <int, int>> wt(n);
for (int i = 0; i < n; i++)
wt[i] = {w[i], i};
sort(wt.begin(), wt.end());
int lo = 0, hi = 0;
long long sum = 0;
while (sum < l || sum > u) {
if (sum < l) {
if (hi == n)
break;
sum += wt[hi].first;
hi++;
} else {
if (lo > hi)
break;
sum -= wt[lo].first;
lo++;
}
}
for (int i = lo; i < hi; i++)
ans.push_back(wt[i].second);
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... |