이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cmath>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include "books.h"
using namespace std;
long long arr[25];
void solve(int N, int K, long long A, int S) {
int low = 1, high = N + 1;
long long C = (A + K - 1) / K, temp;
while (low < high) {
int mid = (low + high) / 2;
if ((temp = skim(mid)) >= C) {
high = mid;
arr[K] = temp;
}
else low = mid + 1;
}
if (low > N) return impossible();
for (int i = 1; i < K; ++i)
arr[K - i] = i < low ? skim(low - i) : (A * 2 + 1);
for (int i = 1; i < K; ++i)
arr[K + i] = i + low <= N ? skim(i + low) : (A * 2 + 1);
for (int i = 1; i <= K; ++i) {
long long sum = accumulate(arr + i, arr + i + K, 0LL);
if (sum >= A && sum <= A * 2) {
vector<int> ans(K);
iota(ans.begin(), ans.end(), low - K + i);
return answer(ans);
}
}
int pos = K;
while (arr[pos] <= A) ++pos;
long long sum = 0;
for (int i = 1; i != K; ++i) sum += arr[i];
if (arr[pos] + sum <= A * 2) {
vector<int> ans(K);
iota(ans.begin(), ans.end(), low - K + 1);
ans[K - 1] = low + pos - K;
return 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... |