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;
vector<int> find_subset(int l, int u, vector<int> w) {
// idea: take advantage of the condition about being bounded above by U-L
// so for given m, it's ok to slide and take w_{i+m} - {w_i} and we'll hit in between due to IVT
int n = w.size();
vector<pair<int, int> > p(n);
for (int i=0; i<n; ++i) p[i] = {w[i], i};
sort(p.begin(), p.end());
ll lo = 0, hi = 0;
int ss = 0;
while (!(lo <= l && u <= hi)) {
if (ss == n) return vector<int>(0); // bad
lo += (ll) p[ss].first;
hi += (ll) p[n-1-ss].first;
ss++;
}
// construct possible
int next = ss;
while (lo < l) {
lo += (ll) p[next].first;
lo -= (ll) p[next-ss].first;
next++;
}
vector<int> ans(ss);
for (int i=0; i<ss; ++i) ans[i] = p[next-ss+i].second;
return ans;
}
# | 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... |