Submission #133017

# Submission time Handle Problem Language Result Execution time Memory
133017 2019-07-20T05:09:54 Z tinjyu Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 504 KB
#include "ricehub.h"
#include <iostream>
using namespace std;
long long int sum[100005],a[100005][2];
int besthub(int R, int L, int X[], long long B)
{
	long long int now=0;
	for(int i=0;i<R;i++)
	{
		sum[i]=sum[i-1]+X[i];
	}
	long long int s=1,e=1;
	long long int ans=0;
	while(s<=e && e<R)
	{
		//cout<<s<<" "<<e<<endl;
		long long int mid=(s+e)/2;
		//cout<<mid<<endl;
		long long int tmp=(X[mid]*(mid-s)-(sum[mid-1]-sum[s-1]+(sum[e]-sum[mid])-X[mid]*(e-mid)));
		//cout<<tmp<<endl;
		if(tmp<=B)
		{
			ans=max(ans,e-s+1);
			e++;
		}
		else s++;
	}
  	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:16: warning: unused variable 'now' [-Wunused-variable]
  long long int now=0;
                ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -