이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
using ll = long long;
void solve(int N, int K, long long A, int S) {
auto my_skim = [&](int pos) {
static vector<ll> memo(N, -1);
if (memo[pos] != -1) return memo[pos];
return memo[pos] = skim(pos + 1);
};
int ok = -1, ng = N - K + 1;
while (ng - ok > 1) {
int mid = (ok + ng) / 2;
ll sm = 0;
rep (i, K) sm += my_skim(mid + i);
if (sm < A) ok = mid;
else ng = mid;
}
if (ok == N - K) {
impossible();
return;
}
{
ll sm = 0;
rep (i, K) sm += my_skim(ok + i + 1);
if (sm <= 2 * A) {
vector<int> ans;
rep (i, K) ans.push_back(ok + i + 2);
answer(ans);
return;
}
}
if (ok == -1) {
impossible();
return;
}
{
ll sm = my_skim(ok + K);
rep (i, K - 1) sm += my_skim(i);
if (sm <= 2 * A) {
vector<int> ans;
rep (i, K - 1) ans.push_back(i + 1);
ans.push_back(ok + K + 1);
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... |