제출 #889555

#제출 시각아이디문제언어결과실행 시간메모리
889555shiomusubi496A Difficult(y) Choice (BOI21_books)C++17
60 / 100
1 ms1444 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 = -1, 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; } } if (ok == -1) { impossible(); 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...