Submission #93996

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
939962019-01-14 13:06:45fjzzq2002쌀 창고 (IOI11_ricehub)C++14
100 / 100
222 ms2664 KiB
#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]
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...