Submission #532676

#TimeUsernameProblemLanguageResultExecution timeMemory
532676safaricolaA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms968 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 ll b[N+5]; memset(b,0,sizeof(b)); int low = 0, high = N + 1; while(high - low >= 2) { int mid = (high + low) / 2; 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])b[i]=skim(i); a[i]=a[i-1]+b[i]; } int c[K+5]; memset(c,0, sizeof(c)); for(int i=high-K+1; i<=high; i++){ if(!b[i])b[i]=skim(i); c[i-(high-K)]=c[i-(high-K)-1]+b[i]; } if(!b[high+1]) skim(high+1); ll cur= b[high+1]; if(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(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:43:8: warning: unused variable 'cur' [-Wunused-variable]
   43 |     ll cur= b[high+1];
      |        ^~~
#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...