이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
long long cache[100005];
long long skimming(int id) {
if(cache[id]!=0)
return cache[id];
return cache[id]=skim(id);
}
void solve(int N, int K, long long A, int S) {
long long sum=0;
for(int i=1;i<K;i++)
sum+=skimming(i);
if(sum>2*A)
impossible();
vector<int> rs;
for(int i=1;i<K;i++)
rs.push_back(i);
int l=K,r=N,pivot=-1;
while(l<=r) {
int mid=(l+r)/2;
if(A<=sum+skimming(mid)&&sum+skimming(mid)<=2*A) {
rs.push_back(mid);
answer(rs);
}
if(sum+skimming(mid)<A) {
pivot=mid;
l=mid+1;
} else
r=mid-1;
}
if(pivot==-1)
impossible();
int cnt=0;
for(int i=rs.size()-1;i>=0;i--) {
sum-=skimming(rs[i]);
cnt++;
sum+=skimming(pivot-cnt);
rs[i]=pivot-cnt;
if(A<=sum+skimming(pivot)&&sum+skimming(pivot)<=2*A) {
rs.push_back(pivot);
answer(rs);
}
}
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... |