Submission #850749

#TimeUsernameProblemLanguageResultExecution timeMemory
850749d4xnA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms1300 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define ll long long const ll N = 1e5+5; ll dp[N]; void solve(int N, int K, long long A, int S) { memset(dp, -1, sizeof(dp)); ll l = 1; ll r = N; while (l < r) { ll mid = (l+r)>>1; if (dp[mid] == -1) dp[mid] = skim(mid); if (dp[mid] < A) l = mid+1; else r = mid; } vector<int> test; test.push_back(l); ll cnt = dp[l]; for (ll i = 1; i <= K-1; i++) { if (dp[i] == -1) dp[i] = skim(i); cnt += dp[i]; test.push_back(i); } if (K-1 < l && A <= cnt && cnt <= A*2) { answer(test); return; } if (K >= l) { impossible(); return; } cnt = 0; for (ll i = 1; i <= K; i++) { if (dp[i] == -1) dp[i] = skim(i); cnt += dp[i]; } if (cnt > 2*A) { impossible(); return; } for (ll i = l-1; i >= l-K; i--) { if (dp[i] == -1) dp[i] = skim(i); } for (ll i = 0; i <= K; i++) { cnt = 0; vector<int> ans; for (ll j = 1; j <= i; j++) { cnt += dp[j]; ans.push_back(j); } for (ll j = 0; j < K-i; j++) { cnt += dp[l-1-j]; ans.push_back(l-1-j); } if (cnt > A && cnt < A*2) { answer(ans); return; } } 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...