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<vector>
#include<cstdio>
#include<set>
#include<cstdlib>
#include<cstdarg>
#include<cassert>
#include"books.h"
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
void solve(int N, int K, long long A, int S) {
ll lo = 1, hi = N, tmp = N + 1, bb = -1;
while(lo <= hi){
int mid = (lo + hi) >> 1;
ll a = skim(mid);
if(a > A)tmp = mid, hi = mid - 1, bb = a;
else lo = mid + 1;
}
ll X[K + 1];
for(int i = 1; i <= K; i++)X[i] = skim(i);
if(tmp <= N && tmp >= K){
ll tot = 0;
for(int i = 1; i <= K - 1; i++)tot += X[i];
tot += bb;
if(tot >= A && tot <= A * 2){
vector <int> ans;
for(int i = 1; i <= K - 1; i++)ans.push_back(i);
ans.push_back(tmp);
answer(ans);
return;
}
}
tmp--;
if(tmp < K){
impossible();
return;
}
ll back[K + 1];
for(int i = tmp; i >= tmp - K + 1; i--)back[tmp - i + 1] = skim(i);
ll tot = 0;
for(int i = 1; i <= K; i++)tot += back[i];
int cur = 0;
while(tot > A * 2 && cur < K){
cur++;
tot += X[cur] - back[cur];
if(tot >= A && tot <= A * 2){
vector <int> ans;
for(int i = 1; i <= cur; i++)ans.push_back(i);
for(int i = tmp - K + cur + 1; i <= tmp; i++)ans.push_back(i);
answer(ans);
return;
}
}
impossible();
}
# | 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... |