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 <map>
using namespace std;
using ll = long long;
vector<int> find_subset(int l, int u, vector<int> w)
{
int n = w.size();
vector<pair<ll, int>> a(n);
for (int i = 0; i < n; ++i) a[i] = {w[i], i};
sort(a.begin(), a.end());
ll sum = 0;
map<ll, int> prefs;
prefs[0] = 0;
for (int i = 0; i < n; ++i)
{
sum += a[i].first;
auto it = prefs.lower_bound(sum - u);
if (it != prefs.end())
{
if (it->first <= sum - l)
{
vector<int> res;
for (int j = it->second; j <= i; ++j) res.push_back(j);
return res;
}
}
prefs[sum] = i + 1;
}
return 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... |