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