이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=100010;
int X[MX], n, xmx;
ll S[MX];
ll _max(ll a, ll b){
return a>b ? a : b;
}
ll cost(int l, int r){
int mid=(l+r)/2;
ll leftsum = 1LL*X[mid]*(mid-l+1) - (S[mid]-S[l-1]);
ll rigtsum = (S[r]-S[mid]) - 1LL*X[mid]*(r-mid);
return leftsum+rigtsum;
}
ll solve(ll maxCost){
ll ans=0;
for(int l=1, r=1; l<=n; l++){
r=max(r,l);
while(r<n && cost(l,r+1)<=maxCost) r++;
if(cost(l,r)>maxCost) continue;
ans=_max(ans, 0LL+r-l+1);
}
return ans;
}
int besthub(int R, int L, int XX[], ll B) {
n=R, xmx=L;
for(int i=1; i<=n; i++){
X[i]=XX[i-1];
S[i]=S[i-1]+X[i];
}
return solve(B);
}
| # | 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... |