이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
//
// --- 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<long long> vals;
long long query(int i) {
if (vals[i] == -1) {
vals[i] = skim(i+1);
}
return vals[i];
}
void solve(int N, int K, long long A, int S) {
vals.assign(N, -1);
int l = 0, r = N - K;
int cand = -1;
while (l <= r) {
int m;
if (r-l >= 100) {
m = l + (r-l)/4;
}
else {
m = l + (r-l)/2;
}
long long tmpSum = 0;
for (int i=K-1;i>=0;i--) {
if (tmpSum + (i+1)*query(m+i) < A) {
tmpSum = -10;
break;
}
tmpSum += query(i+m);
if (tmpSum + i > 2LL*A) {
tmpSum = 2LL*A + 1LL;
break;
}
}
if (A <= tmpSum && tmpSum <= 2LL*A) {
vector<int> idx;
for (int i=0;i<K;i++)idx.push_back(i+m+1);
answer(idx);
return;
}
else if (tmpSum < A) {
l = m+1;
}
else {
r = m-1;
cand = m;
}
}
long long possum = query(cand + K - 1);
for (int i=0;i<K-1;i++) {
possum += query(i);
}
if (A <= possum && possum <= 2*A) {
vector<int> idx;
for (int i=0;i<K-1;i++) idx.push_back(i+1);
idx.push_back(cand+K);
answer(idx);
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... |