이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
else 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... |