# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1032400 | Maite_Morale | A Difficult(y) Choice (BOI21_books) | C++14 | 2 ms | 1364 KiB |
이 제출은 이전 버전의 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.
//
typedef long long ll ;
#define pll pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define vpll vector<pll>
#define vi vector<int>
void solve(int n, int k, long long A, int S) {
vll v(n+5,0);
vi r={};
vpll knowed;
ll s=0;
///*
for(int i=1;i<=k;i++){
r.push_back(i);
v[i]=skim(i);
knowed.push_back({v[i],i});
s+=v[i];
// cout<<"="<<s<<"\n";
if(s>2*A){
impossible();
return;
}
}
if(s>=A){
answer(r);
return;
}
ll last=n+1;
for(int i=k;i>0;i--){
s-=v[i];
ll p=i,f=last;
for(int j=0;j<knowed.size();j++){
if(s+knowed[j].F<A)p=max(p,knowed[j].S);
else if(s+knowed[j].S>2*A)f=min(s,knowed[j].S);
else {
r[i-1]=knowed[j].S;
answer(r);
return;
}
}
if(f<=p){
impossible();
return;
}
// cout<<p<<" "<<f<<"\n";
while(abs(p-f)!=1){
ll md=(p+f)/2;
if(v[md]==0){
v[md]=skim(md);
knowed.push_back({v[i],i});
}
if(s+v[md]<A)p=md;
else if(s+v[md]>2*A)f=md;
else{
r[i-1]=md;
answer(r);
return;
}
// cout<<"="<<s<<"+"<<v[md]<<"\n";
}//for(auto x : r)cout<<x<<" ";cout<<"\n";
r[i-1]=p;
s+=v[p];
last=p;
}
impossible();
}
컴파일 시 표준 에러 (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... |