Submission #943875

#TimeUsernameProblemLanguageResultExecution timeMemory
943875beepbeepsheepA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms620 KiB
#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. // #define ll long long ll arr[100005]; void solve(int N, int K, long long A, int S) { // TODO implement this function ll l=0,r=N+1,m; while (l!=r-1){ m=(l+r)>>1; arr[m]=skim(m); if (arr[m]>=A) r=m; else l=m; } for (int i=1;i<=K;i++) arr[i]=skim(i); for (int i=max(1LL,r-K);i<=min<ll>(r,N);i++) arr[i]=skim(i); ll tot=0; vector<int> out; if (r!=N+1){ for (int i=1;i<K;i++){ tot+=arr[i]; out.emplace_back(i); } tot+=arr[r]; out.emplace_back(r); if (tot>=A && tot<=2*A){ answer(out); return; } out.clear(); } ll lptr=K,rptr=0; while (lptr!=-1){ tot=0; for (int i=1;i<=lptr;i++){ tot+=arr[i]; out.emplace_back(i); } for (int i=r-rptr;i<r;i++){ tot+=arr[i]; out.emplace_back(i); } if (tot>=A && tot<=2*A){ answer(out); return; } out.clear(); lptr--,rptr++; } 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...