Submission #1067050

#TimeUsernameProblemLanguageResultExecution timeMemory
1067050duckindogA Difficult(y) Choice (BOI21_books)C++17
0 / 100
3095 ms1112 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 + 1); for (int i = 1; i <= n; ++i) x[i] = skim(i); vector<bool> mk(n + 1); auto done = [&]() { vector<int> ret; for (int i = 1; i <= n; ++i) if (mk[i]) ret.push_back(i); answer(ret); exit(0); }; long long total = 0; int cnt = 0; int it = n; do { for (int i = it; i >= 1; --i) { if (mk[i]) continue; if (total + x[i] <= 2 * a) { total += x[i]; mk[i] = true; cnt += 1; } if (a <= total && cnt == k) done(); } for (int i = it; i >= 1; --i) { if (mk[i]) { total -= x[i]; mk[i] = false; cnt -= 1; it = i - 1; break; } } } while (true); 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...