제출 #782910

#제출 시각아이디문제언어결과실행 시간메모리
782910HanksburgerA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms304 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; vector<int> ans; int x[100005]; void solve(int n, int k, long long a, int s) { long long l=1, r=n-k+1; while (l<=r) { long long mid=(l+r)/2, sum=0; for (long long i=mid; i<mid+k; i++) { if (!x[i]) x[i]=skim(i); sum+=x[i]; } if (a<=sum && sum<=a*2) { for (long long i=mid; i<mid+k; i++) ans.push_back(i); answer(ans); return; } if (sum<a) l=mid+1; else r=mid-1; } long long pre=0; for (long long i=1; i<k; i++) { if (!x[i]) x[i]=skim(i); pre+=x[i]; } l=k, r=n; while (l<=r) { long long mid=(l+r)/2; if (!x[mid]) x[mid]=skim(mid); if (a<=pre+x[mid] && pre+x[mid]<=a*2) { for (long long i=1; i<k; i++) ans.push_back(i); ans.push_back(mid); answer(ans); return; } if (pre+x[mid]<a) l=mid+1; else r=mid-1; } 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...