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