Submission #207520

# Submission time Handle Problem Language Result Execution time Memory
207520 2020-03-07T17:39:48 Z robs Rice Hub (IOI11_ricehub) C++17
0 / 100
7 ms 504 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define debug(args...) //fprintf(stderr, args)
typedef long long int lli;
using namespace std;
const int maxn = 2e5;
int s[maxn],cX[maxn],I,J,SUM;

int besthub(int R, int L, int X[], long long int B)
{
	s[0] = X[0];
	for(int x = 1; x < R; x++)
		s[x] = s[x-1] + X[x];
	int i = 0;
	int j = 0;
	lli resp = 0;
	while(j < R)
	{
		int med = (i + j) / 2;
		lli sumEsq = (X[med] * i) - s[i];
		lli sumDir = s[j] - (X[med] * j);
		lli sum = sumEsq + sumDir;
		lli r = j - i + 1;
		debug("%d - %d(%d)	%d  %d 		-%d-\n",i,j,sum,sumEsq,sumDir,med);
		if(sum <= B)
		{
			resp = max(resp, r);
			j++;
		}
		else if(i == j)
		{
			j++;
		}
		else	i++;
	}
	return resp;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -