# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582133 | Soumya1 | A Difficult(y) Choice (BOI21_books) | C++17 | 68 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
void solve(int n, int k, long long a, int s) {
int lo = 1, hi = n;
while (lo < hi) {
int mid = (lo + hi) >> 1;
if (skim(mid) >= a) hi = mid;
else lo = mid + 1;
}
vector<pair<long long, int>> b;
for (int i = 1; i <= min(n, 10); i++) b.push_back({skim(i), i});
for (int i = lo; i > max(max(0, lo - 10), min(n, 10)); i--) b.push_back({skim(i), i});
for (int i = 1; i < (1 << b.size()); i++) {
long long sum = 0;
for (int j = 0; j < b.size(); j++) {
if (i & (1 << j)) sum += b[j].first;
}
if (a <= sum && sum <= 2 * a && __builtin_popcount(i) == k) {
vector<int> ans;
for (int j = 0; j < b.size(); j++) {
if (i & (1 << j)) ans.push_back(b[j].second);
}
answer(ans);
return;
}
}
impossible();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |