Submission #64678

# Submission time Handle Problem Language Result Execution time Memory
64678 2018-08-05T11:19:37 Z Abelyan Rice Hub (IOI11_ricehub) C++17
0 / 100
1000 ms 612 KB
#include "ricehub.h"
#include <bits/stdc++.h>
typedef long long ll;
const int N=100050;
ll sum[N];
ll sm(int l, int r){
  return sum[r]-sum[l-1];
}
int besthub(int n, int sz, int x[], ll b)
{
	int i;
	for(i=1;i<=n;i++) sum[i]=sum[i-1]+x[i];
	int r=n,l=1,mid,ans=1;
	while(r>=l)
	{
		mid=l+r/2;
		bool ok=0;
		for(i=mid;i<=n;i++)
		{
			int L=i-mid+1;
			int R=i;
			int M=L+R/2;
			ll cost=(ll)(M-L+1)*x[M]-sm(L,M);
			cost+=sm(M,R)-(ll)(R-M+1)*x[M];
			if(cost<=b){ ok=1;break;}
		}
		if(ok) ans=mid,l=mid+1;
		else r=mid-1;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 612 KB Time limit exceeded
2 Halted 0 ms 0 KB -