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;
using ll = long long;
vector<int> find_subset(int l, int r, vector<int> a) {
int n = a.size();
vector<pair<int,int>> b;
for (int i=0; i<n; i++) b.push_back({a[i], i});
sort(a.begin(), a.end()); sort(b.begin(), b.end());
vector<ll> pre; pre.push_back(0);
for (int x : a) pre.push_back(x + pre.back());
pre.push_back(1e18);
for (int i=n; i>=0; i--) {
ll sum = pre[n] - pre[i];
if (sum > r) break;
int idx = lower_bound(pre.begin(), pre.begin()+i+1, l - sum) - pre.begin();
if (pre[idx] + sum <= r) {
vector<int> ans;
for (int j=0; j<idx; j++) ans.push_back(b[j].second);
for (int j=i; j<n; j++) ans.push_back(b[j].second);
return ans;
}
}
return {};
}
# | 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... |