이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qz[123456];
int besthub(int N,int L_,int X[],ll B)
{
int ans=0;
for(int i=0;i<N;++i)
qz[i+1]=qz[i]+X[i];
for(int i=0;i<N;++i)
{
int u=X[i];
int L=0,R=1.01e9;
while(L<R)
{
int M=(L+R+1)>>1;
int u1=lower_bound(X,X+N,u-M)-X,
u2=lower_bound(X,X+N,u+M+1)-X-1;
//[u1,i] [i,u2]
ll co=(i-u1+1)*ll(u)-(qz[i+1]-qz[u1])
+(qz[u2+1]-qz[i])-(u2-i+1)*ll(u);
int cn=u2-u1+1;
if(co>B) R=M-1; else L=M;
}
{
int M=L;
int u1=lower_bound(X,X+N,u-M)-X,
u2=lower_bound(X,X+N,u+M+1)-X-1;
//[u1,i] [i,u2]
ll co=(i-u1+1)*ll(u)-(qz[i+1]-qz[u1])
+(qz[u2+1]-qz[i])-(u2-i+1)*ll(u);
int cn=u2-u1+1;
ll w=B-co;
if(cn!=N) cn+=w/(M+1);
ans=max(ans,cn);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:23:8: warning: unused variable 'cn' [-Wunused-variable]
int cn=u2-u1+1;
^~
# | 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... |