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>
using namespace std;
typedef long long llong;
struct mole {
int x, i;
bool operator<(const mole &p) const {
return x < p.x;
}
};
int n;
vector<mole> arr;
llong sum[200001];
vector<int> ret;
vector<int> find_subset(int l, int u, vector<int> w) {
arr.resize((n = w.size()) + 1);
arr[0] = { 0, -1 };
for (int i = 0; i < n; ++i) {
arr[i + 1] = { w[i], i };
}
sort(arr.begin() + 1, arr.end());
for (int i = 1; i <= n; ++i) {
sum[i] = sum[i - 1] + arr[i].x;
}
for (int i = 1; i <= n; ++i) {
llong pre, post;
pre = sum[i];
post = sum[n] - sum[n - i];
if (pre < l && post < l) continue;
if (u < pre && u < post) continue;
for (int j = 0;; ++j) {
llong in = sum[j + i] - sum[j];
if (l <= in && in <= u) {
for (int k = 1; k <= i; ++k)
ret.push_back(arr[j + k].i);
return ret;
}
}
}
return ret;
}
# | 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... |