Submission #255126

# Submission time Handle Problem Language Result Execution time Memory
255126 2020-07-31T10:01:07 Z babo Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 768 KB
#include <bits/stdc++.h>

using namespace std;

long long a[100010],nu[100010];
long long n,b;

bool ok(long long x){
	long long i;
	long long sum=0;
	for(i=0;i<n-x+1;i++)
	{
		long long s=i,e=i+x-1,mid=(s+e)/2;
		sum+=a[mid]*(mid-i+1)-(i==0?nu[mid]:(nu[mid]-nu[i-1]));
		sum+=(nu[e]-nu[mid])-a[mid]*(e-mid);
	}
	return sum<=b;
}

int besthub(int R,int L,int *X,long long B){
	long long i;
	for(i=0;i<R;i++)
		a[i]=nu[i]=X[i];
	for(i=1;i<R;i++)
		nu[i]+=nu[i-1];
	n=R,b=B;
	long long s=1,e=R;
	while(s<e)
	{
		long long mid=(s+e+1)/2;
		if(ok(mid)) s=mid;
		else e=mid-1;
	}
	return (int)s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 0 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -