이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1e5+5;
ll sum[mxn];
ll f(int ind){
if(ind<0){
return 0;
}
return sum[ind];
}
ll cal(int l,int r,int arr[]){
int m=(l+r)/2;
ll k=0;
k+=arr[m]*(m-l+1)-(sum[m]-f(l-1));
k+=sum[r]-f(m-1)-arr[m]*(r-m+1);
return k;
}
int besthub(int n, int dis, int arr[], long long k)
{
sum[0]=arr[0];
for(int i=1;i<n;i++){
sum[i]=sum[i-1]+arr[i];
}
int l=0;
int ans=0;
for(int i=0;i<n;i++){
while(cal(l,i,arr)>k){
l++;
}
ans=max(ans,i-l+1);
}
return ans;
}
# | 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... |