제출 #943872

#제출 시각아이디문제언어결과실행 시간메모리
943872beepbeepsheepA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms628 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<=r;i++) arr[i]=skim(i); ll tot=0; vector<int> out; 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...