제출 #547062

#제출 시각아이디문제언어결과실행 시간메모리
547062MilosMilutinovicA Difficult(y) Choice (BOI21_books)C++14
100 / 100
3 ms336 KiB
#include "books.h" using namespace std; #define N 100000 static long long aa[N + 1]; void solve(int n, int k, long long a, int s) { vector<int> ii(k); int i, lower, upper; long long sum; lower = 1, upper = n + 1; while (upper - lower > 1) { i = (lower + upper) / 2; if ((aa[i] = skim(i)) >= a) upper = i; else lower = i; } if (upper < k) { impossible(); return; } for (i = 1; i <= k; i++) aa[i] = skim(i); if (upper <= n) { sum = aa[upper]; for (i = 1; i < k; i++) sum += aa[i]; if (sum <= a * 2) { for (i = 1; i < k; i++) ii[i - 1] = i; ii[k - 1] = upper; answer(ii); return; } if ((n = upper - 1) < k) { impossible(); return; } } sum = 0; for (i = 1; i <= k; i++) ii[i - 1] = i, sum += aa[i]; if (sum >= a && sum <= 2 * a) { answer(ii); return; } for (i = k; i >= 1; i--) { ii[i - 1] = n - (k - i), sum += skim(n - (k - i)) - aa[i]; if (sum >= a && sum <= 2 * a) { answer(ii); 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...