이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
map <int, int> mp;
int all(int k, int p) {
long long sum = 0;
for (int i = 0; i < k; i++) {
int pos = i + 1 + p;
if (mp.find(pos) == mp.end()) {
mp[pos] = skim(pos);
sum += mp[pos];
}
}
return sum;
}
void solve(int N, int K, long long A, int S) {
long long l = 0, r = N - K - 1, left = 2 * A / K, rr = (K + 1 + A) / K;
while (l <= r) {
long long mid = (l + r) / 2, lll = all(1, mid), rrr = all(1, mid + K - 1);
if (left < lll) {
r = mid;
}
else if (rr < rrr) {
l = mid + 1;
}
else {
if (A * 2 < all(K, mid)) {
r = mid - 1;
}
else if (A > all(K, mid)) {
l = mid + 1;
}
else {
vector <int> st;
for (int i = 0; i < K; i++) {
int pos = mid + i + 1;
st.push_back(pos);
}
answer(st);
return;
}
}
}
l = K;
r = N - 1;
while (l <= r) {
int mid = (l + r) / 2;
if (A * 2 < (all(K - 1, 0) + all(1, mid))) {
r = mid - 1;
}
else if (A > (all(K - 1, 0) + all(1, mid))) {
l = mid + 1;
}
else {
vector <int> st;
for (int i = 0; i < K - 1; i++) {
int pos = i + 1;
st.push_back(pos);
}
st.push_back(mid + 1);
answer(st);
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... |