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 <bits/stdc++.h>
using namespace std;
#include "molecules.h"
std::vector<int> find_subset(int l, int u, vector<int> w) {
sort(w.begin(), w.end());
int n = w.size();
int length = 0;
long long sum = 0;
for (; length < n; length++)
{
if (sum + w[length] <= u) {
sum += w[length];
} else break;
}
vector<int> result(length);
for (int i = 0; i < length; i++) {
result[i] = w[i];
}
if (sum >= l) {
return result;
}
for (int i = length - 1; i >= 0; i--)
{
sum -= result[i];
result[i] = w[n - length + i];
sum += result[i];
if (sum >= l) {
return result;
}
}
return std::vector<int>(0);
}
# | 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... |