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) {
vector<pair<int,int>> a;
for (int i = 0; i < (int)w.size(); ++i)
a.push_back({w[i], i});
sort(a.begin(), a.end(), greater<pair<int,int>>());
queue<int> q;
vector<int> ans;
long long s = 0;
for (int i = 0; i < (int)a.size(); ++i) {
q.push(a[i].second);
s += a[i].first;
if (l <= s && s <= u) break;
while (!q.empty() && s > u) {
s -= w[q.front()];
q.pop();
}
}
if (s < l || s > u) return vector<int>(0);
while (!q.empty()) {
ans.push_back(q.front() + 1);
q.pop();
}
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... |