Submission #234947

# Submission time Handle Problem Language Result Execution time Memory
234947 2020-05-26T12:00:07 Z Nodir_Bobiev Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 2304 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	int ans = 0;
	long long sumL[R+2]={}, sumR[R+2]={};
	for( int i = 1; i <= R; i ++ ){
		sumL[i] = sumL[i-1] + X[i-1];
	}
	for( int i = R; i >= 1; i -- ){
		sumR[i] = sumR[i+1] + X[i-1];
	}
	for( int i = 1; i <= R; i ++ ){
		int l = 1, r = R+1;
		while( r - l > 1 ){
			int m = ( l + r ) >> 1;
			long long mn = 1e18;
			for( int j = max(i-m+1,1); j <= min(i,R-m+1); j++){
				int k = j + m-1;
				mn = min(mn, X[i-1]*1ll*(i-j+1)-(sumL[i]-sumL[j-1]) + 
							(sumR[i]-sumR[k+1])-X[i-1]*1ll*(k-i+1)  );
			}
			if( mn <= B )
				l = m;
			else
				r = m;
		}
		ans = max(l, ans);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 6 ms 360 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 40 ms 504 KB Output is correct
22 Correct 39 ms 384 KB Output is correct
23 Correct 34 ms 384 KB Output is correct
24 Correct 47 ms 384 KB Output is correct
25 Correct 43 ms 384 KB Output is correct
26 Correct 50 ms 384 KB Output is correct
27 Correct 114 ms 384 KB Output is correct
28 Correct 116 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 407 ms 768 KB Output is correct
2 Correct 402 ms 888 KB Output is correct
3 Execution timed out 1095 ms 2304 KB Time limit exceeded
4 Halted 0 ms 0 KB -