이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |