이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long ll;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
void solve(int N, int K, ll A, int S) {
int l = 0, r = N, ans = -1;
while (l <= r){
if (l == r){
ans = l;
break;
}
int m = (l + r) >> 1;
ll res = skim(m);
if (res * K < A) l = m + 1;
else if (res * K > 2 * A) r = m - 1;
else{
ans = m;
break;
}
}
vector<pair<int, ll>> vec;
vec.push_back({ans, skim(ans)});
for (int k = 1; k <= 10 && ans - k >= 1; k++) vec.push_back({ans - k, skim(ans - k)});
for (int k = 1; k <= 10 && ans + k <= N; k++) vec.push_back({ans + k, skim(ans + k)});
sort(vec.begin(), vec.end());
int sz = vec.size();
vector<int> perm;
for (int i = sz - 1; i >= 0; i--) perm.push_back(i < K);
do{
ll ans = 0;
vector<int> vans;
for (int i = 0; i < sz; i++)
if (perm[i]){
vans.push_back(vec[i].first);
ans += vec[i].second;
}
if (ans >= A && ans <= 2 * A) answer(vans);
} while (next_permutation(perm.begin(), perm.end()));
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... |