이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using ll = long long;
template <class T> using Vec = std::vector<T>;
void solve(int N, int K, ll A, int S) {
int ok = N + 1, ng = 0;
while (ok - ng > 1) {
const int md = (ok + ng) / 2;
(skim(md) >= A ? ok : ng) = md;
}
Vec<std::pair<ll, int>> cand;
for (int i = 1; i <= std::min(K, ok - 1); ++i) {
cand.emplace_back(skim(i), i);
}
for (int i = std::max(K + 1, ok - K); i <= ok - 1; ++i) {
cand.emplace_back(skim(i), i);
}
if (ok <= N and (int) cand.size() >= K - 1) {
const auto val = skim(ok);
ll sum = 0;
for (int i = 0; i < K - 1; ++i) {
sum += cand[i].first;
}
if (sum + val <= 2 * A) {
Vec<int> ans;
for (int i = 0; i < K - 1; ++i) {
ans.push_back(cand[i].second);
}
ans.push_back(ok);
answer(ans);
return;
}
}
for (int set = 0; set < (1 << cand.size()); ++set) {
if (__builtin_popcount(set) != K) {
continue;
}
ll sum = 0;
for (int i = 0; i < (int) cand.size(); ++i) {
if (set >> i & 1) {
sum += cand[i].first;
}
}
if (A <= sum and sum <= 2 * A) {
Vec<int> ans;
for (int i = 0; i < (int) cand.size(); ++i) {
if (set >> i & 1) {
ans.push_back(cand[i].second);
}
}
answer(ans);
return;
}
}
impossible();
}
# | 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... |