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;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const vector<int> e = {};
int n;
vector<ll> v;
vector<int> idx;
ll a, b;
vector<int> construct(int l, int r) {
vector<int> result;
for(int i = l; i <= r; i++) {
result.pb(idx[i] - 1);
}
return result;
}
vector<int> solve() {
idx.assign(1 + n + 1, 0);
vector<pair<ll, int> > p(1 + n + 1, mp(0, 0));
for(int i = 1; i <= n; i++) {
p[i].fi = v[i];
p[i].se = i;
}
sort(p.begin() + 1, p.end() - 1);
for(int i = 1; i <= n; i++) {
idx[i] = p[i].se;
}
ll sum = 0, len = -1;
for(int i = 1; i <= n; i++) {
sum += v[i];
if(sum >= a) {
if(sum <= b) {
return construct(1, i);
}
len = i - 1;
break;
}
}
if(len == -1) {
return e;
}
sum = 0;
int l = 1, r = len;
for(int i = 1; i <= len; i++) {
sum += v[i];
}
while(r <= n) {
if(sum >= a && sum <= b) {
return construct(l, r);
}
sum -= v[l];
l++;
r++;
sum += v[r];
}
return e;
}
vector<int> find_subset(int l, int u, vector<int> w) {
n = w.size();
v.assign(1 + n + 1, 0);
for(int i = 1; i <= n; i++) {
v[i] = w[i - 1];
}
a = l;
b = u;
return solve();
}
# | 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... |