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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 2e5+5;
ll pre[MAXN];
pii arr[MAXN];
int n;
ll sum(int l, int r) {
return pre[r+1]-pre[l];
}
vector<int> find_subset(int l, int r, vector<int> w) {
n = w.size();
for (int i = 0; i < n; i++) {
arr[i] = pii(w[i], i);
}
sort(arr, arr+n);
for (int i = 1; i <= n; i++) pre[i] = pre[i-1]+arr[i-1].first;
for (int i = 0; i < n; i++) {
if (sum(0, i) > r || sum(n-i-1, n-1) < l) continue;
vector<int> ans;
int num = i+1;
int incl = 0;
for (int j = 0; j < n && num; j++) {
assert(j+num <= n);
if (incl+sum(j, j+num-1) <= r && incl+arr[j].first+sum(n-num+1, n-1) >= l) {
ans.push_back(arr[j].second);
incl += arr[j].first;
num--;
}
}
assert(l <= incl && incl <= r);
return ans;
}
return vector<int>();
}
# | 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... |