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;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int N = (int)2e5+10;
int n;
ll a[N], pref[N];
ll Skim(int i){
if(a[i]!=-1) return a[i];
return a[i]=skim(i);
}
ll sum(int mid, int num){
ll s = 0;
for(int j = mid; j < mid+num; j++) s+=Skim(j);
return s;
}
void solve(int _N, int K, ll A, int S) {
n = _N; memset(a,-1,sizeof(a));
int l = 1, r = n-K+1;
while(l<r){
int mid = (l+r+1)/2;
int xd = sum(mid,K);
if(xd>=A and xd<=2*A){
vi ans(K,0); iota(all(ans),mid); answer(ans);
return;
}
if(xd>2*A) r=mid-1;
else l=mid+1;
}
int xd = sum(l,K);
if(xd>=A and xd<=2*A){
vi ans(K,0); iota(all(ans),l); 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... |