Submission #889552

#TimeUsernameProblemLanguageResultExecution timeMemory
889552shiomusubi496A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms1200 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i) using ll = long long; void solve(int N, int K, long long A, int S) { auto my_skim = [&](int pos) { static vector<ll> memo(N, -1); if (memo[pos] != -1) return memo[pos]; return memo[pos] = skim(pos + 1); }; int ok = 0, ng = N - K + 1; while (ng - ok > 1) { int mid = (ok + ng) / 2; ll sm = 0; rep (i, K) sm += my_skim(mid + i); if (sm < A) ok = mid; else ng = mid; } if (ok == N - K) { impossible(); return; } { ll sm = 0; rep (i, K) sm += my_skim(ok + i + 1); if (sm <= 2 * A) { vector<int> ans; rep (i, K) ans.push_back(ok + i + 2); answer(ans); return; } } { ll sm = my_skim(ok + K); rep (i, K - 1) sm += my_skim(i); if (sm <= 2 * A) { vector<int> ans; rep (i, K - 1) ans.push_back(i + 1); ans.push_back(ok + K + 1); 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...