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 <bits/stdc++.h>
#include "books.h"
using namespace std;
const int MAXN = (int) 1e5+5;
typedef long long ll;
ll arr[MAXN];
int k;
ll ask(int idx){
if(arr[idx] != -1)
return arr[idx];
return arr[idx] = skim(idx);
}
ll ask(vector<int> a){
ll res = 0;
for(int j: a){
res += ask(j);
}
return res;
}
vector<int> get(int idx){
vector<int> ans;
for(int i = idx; i < idx + k; i++)
ans.push_back(i);
return ans;
}
void solve(int N, int K, long long A, int S) {
k = K;
memset(arr, -1, sizeof(arr));
int l = 1, r = N - K + 1;
while(l < r){
int m = (l + r) / 2;
ll res = ask(get(m));
if(res >= A && res <= 2*A){
l = m;
r = m;
}else if(res < A){
l = m + 1;
}else if(res > 2*A){
r = m - 1;
}
}
l = min(l, N - K + 1);
if(ask(get(l)) >= A && ask(get(l)) <= 2*A){
answer(get(l));
}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... |