제출 #529746

#제출 시각아이디문제언어결과실행 시간메모리
529746mjhmjh1104A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms280 KiB
#include <map> #include "books.h" using namespace std; map<int, long long> m; int s; long long ask(int x) { if (s) { s--; return skim(x); } else return (long long)-1; } long long get(int x, int K) { long long ret = 0; for (int i = 0; i < K; i++) { if (m.find(x + i + 1) == m.end()) m[x + i + 1] = ask(x + i + 1); ret += m[x + i + 1]; if (ret > (long long)4e18) ret = (long long)4e18; } return ret; } void solve(int N, int K, long long A, int S) { s = S; int l = 0, r = N - K; while (l < r) { int m = (l + r) / 2; long long t = get(m, 1); if (t < A / K) l = m + 1; else r = m; } long long sum = 0; for (int i = l; i < l + K; i++) { sum += get(i, 1); if (sum > 2 * A) break; if (sum > A) { vector<int> v; for (int j = 0; j < K; j++) v.push_back(i - K + j + 1); answer(v); return; } } if (l >= N) { impossible(); return; } r = 0; while (r + K - 1 <= l && r <= 0) { if (get(r, K - 1) + get(l, 1) > 2 * A) break; if (get(r, K - 1) + get(l, 1) >= A || s <= 0) { vector<int> v; for (int i = 0; i < K - 1; i++) v.push_back(r + i + 1); v.push_back(l + 1); answer(v); return; } r++; } 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...