Submission #530159

#TimeUsernameProblemLanguageResultExecution timeMemory
530159benedict0724A Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms288 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int N, int K, long long A, int S) { int l = 1, r = N+1; while(l < r) { int mid = (l + r)/2; if(skim(mid) > A) r = mid; else l = mid + 1; } if(l < K) { impossible(); return; } if(l == K) { long long ans = 0; for(int i=1;i<=K;i++) ans += skim(i); vector<int> v; for(int i=1;i<=K;i++) v.push_back(i); if(A <= ans && ans <= 2*A) answer(v); else impossible(); return; } long long a[11], b[11]; for(int i=1;i<=K;i++) { a[i] = skim(i); b[i] = skim(l-K+i-1); } long long ans = 0; vector<int> v; if(l <= N) { for(int i=1;i<K;i++) ans += a[i]; ans += skim(l); if(A <= ans && ans <= 2*A) { for(int i=1;i<K;i++) v.push_back(i); v.push_back(l); answer(v); return; } } ans = 0; for(int i=1;i<=K;i++) ans += a[i]; if(ans > 2*A) { impossible(); return; } for(int i=1;i<=K;i++) v.push_back(i); for(int i=K;i>=0;i--) { if(A <= ans && ans <= 2*A) { answer(v); return; } if(i == 0) break; v[i-1] = l-K+i-1; ans += b[i] - a[i]; } 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...