이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define vv vector<long long>
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define mkp make_pair
#define INF 1000000003
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.
//
void solve(int N, int K, long long A, int S) {
// TODO implement this function
vector<long long> v(N);
int y=A/K;
int l=1;
int r=N;
while (l+1<r){
int m=(l+r)>>1;
long long k=skim(m);
if (k>y)r=m;
else l=m;
}
v.resize(K+1);
long long sum=0;
if (l!=1)l--;
FOR(i,0,K){
if (l+i>N){
impossible();
return;
}
v[i]=skim(l+i);
sum+=v[i];
}
vector<int> ans;
if (sum>=A && sum<=2*A){
FOR(i,0,K)ans.push_back(l+i);
answer(ans);
return;
}
if (l+K<=N){
sum+=skim(l+K);
sum-=v[0];
l++;
if (sum>=A && sum<=2*A){
FOR(i,0,K)ans.push_back(l+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... |