Submission #550363

#TimeUsernameProblemLanguageResultExecution timeMemory
550363Zhora_004A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms988 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int n, int k, long long a, int s) { vector<long long> x(n); vector<int> vec; long long sum = 0; for (int i = 0; i < k - 1; i++) { x[i] = skim(i + 1); sum += x[i]; vec.push_back(i + 1); } int l = k - 1, r = n; while (l != r) { int m = (l + r) >> 1; if (x[m] == 0) x[m] = skim(m + 1); if (x[m] <= a) l = m + 1; else r = m; } if (r < n) { sum += x[r]; vec.push_back(r + 1); if (a <= sum && sum <= a * 2) answer(vec); } vector<long long> nums; for (int i = 0; i < k; i++) { if (x[i] == 0) x[i] = skim(i + 1); nums.push_back(i + 1); } for (int i = max(k, r - k); i < r; i++) { if (x[i] == 0) x[i] = skim(i + 1); nums.push_back(i + 1); } for (int i = 0; i + k - 1 < (int)(nums.size()); i++) { sum = 0; vec.clear(); for (int j = i; j <= i + k - 1; j++) { sum += x[nums[j]]; vec.push_back(nums[j] + 1); } if (a <= sum && sum <= a * 2) answer(vec); } 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...