Submission #133014

# Submission time Handle Problem Language Result Execution time Memory
133014 2019-07-20T05:03:30 Z tinjyu Rice Hub (IOI11_ricehub) C++14
17 / 100
18 ms 1500 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)
{
	int now=0;
	for(int i=0;i<R;i++)
	{
		sum[i]=sum[i-1]+X[i];
	}
	int s=1,e=1;
	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+1)-(sum[mid]-sum[s-1])+(sum[e]-sum[mid-1])-X[mid]*(e-mid+1));
		//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:6: warning: unused variable 'now' [-Wunused-variable]
  int now=0;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 2 ms 380 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 18 ms 1500 KB Output isn't correct
4 Halted 0 ms 0 KB -