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 <iostream>
#include <bitset>
#include <vector>
using namespace std;
using llong = long long;
const int maxN = 200000;
struct Int
{
llong num;
int ind;
operator llong&() { return num; }
operator const llong&() const { return num; }
};
llong pref[maxN];
inline llong Sum(int l, int r) { return pref[r] - (l ? pref[l - 1] : 0); }
vector<int> find_subset(int l, int u, vector<int> a)
{
int m = a.size();
vector<Int> w(m);
for (int i = 0; i < m; ++i)
w[i] = {a[i], i};
sort(w.begin(), w.end());
for (int i = 0; i < m; ++i)
pref[i] = (i ? pref[i - 1] : 0) + w[i];
for (int n = 1; n <= m; ++n)
{
int mnsum = pref[n - 1], mxsum = Sum(m - n, m - 1);
if (mnsum <= u && l <= mxsum)
{
for (int i = 0; i + n - 1 < m; ++i)
if (l <= Sum(i, i + n - 1) && Sum(i, i + n - 1) <= u)
{
vector<int> res;
for (int j = i; j <= i + n - 1; ++j)
res.push_back(w[j].ind);
return res;
}
}
}
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... |