제출 #529030

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