Submission #1115296

#TimeUsernameProblemLanguageResultExecution timeMemory
1115296Dan4LifeA Difficult(y) Choice (BOI21_books)C++17
0 / 100
3099 ms3152 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)2e5+10; int n; ll a[N], pref[N]; ll Skim(int i){ if(a[i]!=-1) return a[i]; return a[i]=skim(i); } void solve(int _N, int K, ll A, int S) { n = _N; memset(a,-1,sizeof(a)); int l = 1, r = n-K+1; while(l<r){ int mid = (l+r+1)/2; ll sum = 0; vi ans(K,0); for(int j = mid; j < mid+K; j++) sum+=Skim(j); iota(all(ans),mid); if(sum>=A and sum<=2*A){ answer(ans); return; } if(sum<A){ int l2 = mid+K, r2 = n; while(l2<r2){ int mid2 = (l2+r2+1)/2; int nsum = sum+Skim(mid2); if(nsum>=A and nsum<=2*A){ ans[K-1] = mid2; answer(ans); return; } if(nsum>2*A) r2=mid-1; else l2=mid; } } if(sum>=2*A) r=mid-1; else l=mid; } 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...