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<bits/stdc++.h>
#include "books.h"
using namespace std;
using ll = long long;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)x.size()
//#define endl '\n'
void solve(int n, int k, ll a, int s) {
ll begs[k + 1];
ll ends[k + 1];
for (int i = 1; i <= k; i++) {
begs[i] = skim(i);
}
for (int i = 1; i <= k; i++) {
ends[i] = skim(n + 1 - i);
}
for (int i = 2; i <= k; i++) {
begs[i] += begs[i - 1];
ends[i] += ends[i - 1];
}
if (begs[k] > 2 * a || ends[k] < a) {
impossible();
return;
}
int cnt = k - 1;
for (int i = 0; i < k; i++) {
if (begs[i] + ends[k - i] >= a && begs[i + 1] + ends[k - (i + 1)] <= a) {
cnt = i;
break;
}
}
int l = cnt;
int r = n - (k - (cnt + 1));
while (l + 1 != r) {
int m = (l + r + 1) / 2;
int val = skim(m);
if (begs[cnt] + val + ends[r - (k - (cnt + 1))] >= a) {
r = m;
}
else {
l = m;
}
}
vector<int> v;
for (int i = 1; i <= cnt; i++) {
v.pb(i);
}
v.pb(r);
for (int i = n - (k - (cnt + 1)) + 1; i <= n; i++) {
v.pb(i);
}
answer(v);
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |