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>
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pii> v(n + 1);
for (int i = 0; i < n; i++) {
v[i + 1] = {w[i], i};
}
sort(v.begin() + 1, v.end(), greater<pii>());
int ptr = 0;
ll int sum = 0;
for (int i = 1; i <= n; i++) {
if (sum <= 0) {
sum = 0;
ptr = i - 1;
}
while (ptr < n && sum < l) {
ptr++;
sum += v[ptr].ff;
}
if (l <= sum && sum <= u) {
vector<int> res;
for (int j = i; j <= ptr; j++) {
res.pb(v[j].ss);
}
return res;
}
sum -= v[i].ff;
}
return {};
}
# | 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... |