이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e)?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
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.
//
ll n,k,a,s;
map<int,ll> memo;
ll ask(int i){
if (memo.count(i)) return memo[i];
else return memo[i]=skim(i);
}
void solve(int N, int K, long long A, int S) {
n=N,k=K,a=A,s=S;
ll tot=0;
vector<int> ans;
rep(x,1,k+1){
tot+=ask(x);
ans.pub(x);
}
if (a<=tot && tot<=2*a){
answer(ans);
return;
}
if (2*a<tot){
impossible();
return;
}
int lo=1,hi=n+1,mi;
while (hi-lo>1){
mi=hi+lo>>1;
if (ask(mi)<=a) lo=mi;
else hi=mi;
}
if (lo!=n){
ll temp=tot-ask(k)+ask(lo+1);
if (a<=temp && temp<=2*a){
ans.back()=lo+1;
answer(ans);
return;
}
}
rep(x,0,k){
ans[k-1-x]=lo-x;
tot-=ask(k-x);
tot+=ask(lo-x);
//cout<<tot<<endl;
if (tot<a) continue;
if (tot<=2*a){
answer(ans);
return;
}
}
impossible();
}
컴파일 시 표준 에러 (stderr) 메시지
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:65:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
65 | mi=hi+lo>>1;
| ~~^~~
# | 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... |