이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define ll long long
using namespace std;
void solve(int N, int K, ll A, int S){
int x = 0;
for(int y=1<<19; y/=2; )
if(x + y <= N && skim(x + y) < A) x += y;
++x;
vector<pair<int, ll>> vals;
for(int i=1; i<=K; ++i) vals.emplace_back(i, skim(i));
for(int i=max(K+1, x-K); i<x; ++i) vals.emplace_back(i, skim(i));
if(x<=N) vals.emplace_back(x, skim(x));
for(int i=1; i<=K+K; ++i){
if(i+K-1 > (int)vals.size()) break;
ll sum = 0;
vector<int> res(K);
for(int j=0; j<K; ++j) sum += vals[i+j-1].second, res[j] = vals[i+j-1].first;
if(A<=sum && sum<=A+A) return answer(res);
}
if(x <= N){
ll sum = 0;
vector<int> res(K);
for(int i=1; i<K; ++i) sum += vals[i-1].second, res[i-1] = i;
sum += skim(x);
res[K-1] = x;
if(A<=sum && sum<=A+A) return answer(res);
}
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... |