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