이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Be name khoda //
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long ll;
const int maxn5 = 3e5 + 10;
const int lg = 20;
#define pb push_back
#define se second
#define fi first
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
vector <int> ret;
ll a[maxn5];
inline ll req(int i){
if(a[i] != -1)
return a[i];
a[i] = skim(i);
return a[i];
}
void solve(int N, int K, long long A, int S) {
int n = N;
int k = K;
memset(a, -1, sizeof a);
//cout << 1 / 0 << endl;
int lo = 0, hi = n + 1;
while(hi - lo > 1){
int mid = (lo + hi) >> 1;
if(req(mid) <= A)
lo = mid;
else
hi = mid;
}
if(lo == 0)
impossible();
if(lo < n){
ll have = 0;
for(int i = 1; i < k; i++)
have += req(i);
if(have + req(hi) <= 2 * A){
for(int i = 1; i < k; i++)
ret.pb(i);
ret.pb(hi);
answer(ret);
}
}
for(int i = 0; i <= k; i++){
ll have = 0;
for(int r = 1; r <= i; r++)
have += req(r);
for(int r = lo - (k - i) + 1; r <= lo; r++)
have += req(r);
if(have >= A && have <= 2 * A){
for(int r = 1; r <= i; r++)
ret.pb(r);
for(int r = lo - (k - i) + 1; r <= lo; r++)
ret.pb(r);
answer(ret);
}
}
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... |