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 <cmath>
#include <cassert>
#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) {
for (int i = 1; i != K; ++i) arr[i] = skim(i);
long long sum = accumulate(arr + 1, arr + K, 0LL);
int low = K, high = N + 1;
while (low < high) {
int mid = (low + high) / 2;
if (skim(mid) + sum >= A) high = mid;
else low = mid + 1;
}
if (low <= N && skim(low) + sum <= A * 2) {
vector<int> ans(K); iota(ans.begin(), ans.end(), 1);
ans[K - 1] = low;
return answer(ans);
}
if (low == K) return impossible();
for (int i = 1; i <= K; ++i) {
sum += skim(low - i) - arr[K + 1 - i];
if (sum >= A) {
assert(sum <= A * 2);
vector<int> ans(K); iota(ans.begin(), ans.end() - i, 1);
iota(ans.end() - i, ans.end(), low - i);
return answer(ans);
}
}
}
# | 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... |