Submission #1115437

#TimeUsernameProblemLanguageResultExecution timeMemory
1115437Dan4LifeA Difficult(y) Choice (BOI21_books)C++17
10 / 100
4 ms1336 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; const int N = (int)1e5+10; int n, K; ll A, a[N]; vi ans; ll Skim(int i){ if(a[i]!=-1) return a[i]; return a[i]=skim(i); } ll getSum(int mid, int num){ ll s = 0; for(int j = mid; j < mid+num; j++) s+=Skim(j); return s; } void bsearch(int st, ll sum){ int l = st+K, r = n; while(l<r){ int mid = (l+r)/2; ll sum2 = sum+Skim(mid); if(sum2>=A and sum2<=2*A){ ans[K-1] = mid; answer(ans); return; } if(sum2>2*A) r=mid-1; else l=mid; } } ll chk(int mid){ ll sum = getSum(mid,K); ans.resize(K,0); iota(all(ans),mid); if(sum>=A and sum<=2*A){ answer(ans); exit(0); } //bsearch(mid,sum-a[mid+K-1]); return sum; } void solve(int _N, int _K, ll _A, int S) { n = _N; A=_A,K=_K; memset(a,-1,sizeof(a)); ans.resize(K,0); int l = 1, r = n-K+1; while(l<r){ int mid = (l+r)/2; if(chk(mid)>2*A) r=mid-1; else l=mid+1; } chk(l); 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...