# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
950111 | pcc | A Difficult(y) Choice (BOI21_books) | C++17 | 2 ms | 688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
//
// --- 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.
//
/*
if (skim(2) == 42) {
impossible();
} else {
answer({1, 3});
}
*/
map<ll,ll> mp;
ll ask(int k){
if(mp.find(k) != mp.end())return mp[k];
else return mp[k] = skim(k);
}
void solve(int N, int K, long long A, int S) {
// TODO implement this function
vector<pll> v;
ll sum = 0;
ll big = 0;
ll l = 1,r = N+1;
while(l != r){
ll mid = (l+r)>>1;
if(ask(mid)>=A)r = mid;
else l = mid+1;
}
big = r;
if(big<=N&&big>=K){
ll sum = ask(big);
vector<int> v;
v.push_back(big);
for(int i = 1;i<K;i++){
v.push_back(i);
sum += ask(i);
}
if(sum>=A&&sum<=A*2){
answer(v);
return;
}
}
if(big<K){
impossible();
return;
}
for(int i = 1;i<=K;i++){
v.push_back(pll(i,ask(i)));
sum += v.back().sc;
}
for(int i = K-1;i>=0;i--){
if(sum>=A&&sum<=A*2)break;
ll l = i+1,r = (i+1==v.size()?big-1:v[i+1].fs-1);
while(l != r){
ll mid = (l+r)>>1;
if(ask(mid)+sum-v[i].sc>=A)r = mid;
else l = mid+1;
}
sum -= v[i].sc;
v[i] = pll(l,ask(l));
sum += v[i].sc;
}
if(sum<A||sum>A*2){
impossible();
return;
}
vector<int> ans;
for(auto &i:v)ans.push_back(i.fs);
answer(ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |