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 <algorithm>
#include <vector>
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
std::vector<int> vec;
long long int sum = 0;
int n = w.size();
std::pair<int, int> a[200010];
for (int i = 0; i < n; ++i)
{
a[i].first = w[i];
a[i].second = i;
}
std::sort(a, a + n);
int last = -1;
for (int i = n - 1; i >= 0; --i)
{
sum += a[i].first;
if (sum >= l)
{
last = i;
break;
}
}
if (last == -1)
return vec;
if (sum >= l && sum <= u)
{
for (int i = n - 1; i >= last; --i)
{
vec.push_back(a[i].second);
}
return vec;
}
for (int i = last - 1, j = 1; i >= 0; --i, ++j)
{
sum -= a[n - j].first;
sum += a[i].first;
if (sum <= u)
{
for (int k = i; k < n - j; ++k)
{
vec.push_back(a[k].second);
}
return vec;
}
}
return vec;
}
# | 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... |