Submission #532801

#TimeUsernameProblemLanguageResultExecution timeMemory
532801safaricolaA Difficult(y) Choice (BOI21_books)C++17
45 / 100
2 ms1060 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; typedef pair<ll,ll> ii; // // --- 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 int count=0; ll b[N+5]; memset(b,0,sizeof(b)); int low = 0, high = N + 1; while(high - low >= 2) { int mid = (high + low) / 2; count++; assert(count<S); b[mid]=skim(mid); if(b[mid] < A) low = mid; else high = mid; } ll a[K+5]; memset(a,0,sizeof(a)); //cout<<low<<endl; high=low; if(high<=K-2)impossible(); for(int i=1; i<=K; i++){ if(!b[i]){ count++; assert(count<S); b[i]=skim(i); } a[i]=a[i-1]+b[i]; } ll c[K+5]; memset(c,0, sizeof(c)); for(int i=high; i>=max(high-K+1,1); i--){ if(!b[i]){ count++; assert(count<S); b[i]=skim(i); } c[high-i+1]=c[high-i]+b[i]; } //for(int i=1; i<=K; i++)cout<<c[i]<<" "; // cout<<endl; if(high<N && !b[high+1]){ count++; assert(count<S); b[high+1]=skim(high+1); } if(high<N && b[high+1]+a[K-1]<2*A){ vector<int> v; for(int i=1; i<=K-1; i++){ v.push_back(i); } v.push_back(high+1); answer(v); }else{ for(int i=0; i<=K;i++){ //printf("i=%d, sum=%lld \n", i,a[i]+c[K-i]); if(a[i]+c[K-i]>=A && a[i]+c[K-i]<=2*A){ vector<int> v; for(int j=1; j<=i; j++){ v.push_back(j); } for(int j=0; j<K-i; j++){ v.push_back(high-j); } answer(v); } } } impossible(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...