Submission #234993

# Submission time Handle Problem Language Result Execution time Memory
234993 2020-05-26T15:17:27 Z Nodir_Bobiev Rice Hub (IOI11_ricehub) C++17
100 / 100
34 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];
    	}
    	int l = 1, r = 1;
    	while( r <= R ){
    		//cout << l << ' '<< r << endl;
    		long long ll = (l+r)>>1;
    		bool t = false;
    		if( X[ll-1]*(ll-l+1)-(sumL[ll]-sumL[l-1])+
    			(sumR[ll]-sumR[r+1])-X[ll-1]*(r-ll+1) <= B )
    			t = true;
    		if( ++ll <= r && X[ll-1]*(ll-l+1)-(sumL[ll]-sumL[l-1])+
    						(sumR[ll]-sumR[r+1])-X[ll-1]*(r-ll+1) <= B )
    			t = true;
    		if( t ){
    			ans = max(ans, r-l+1);
    			r++;
    		}
    		else l ++;
    	}
    	return ans;
    }
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 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 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 768 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 23 ms 2304 KB Output is correct
4 Correct 22 ms 2304 KB Output is correct
5 Correct 12 ms 1280 KB Output is correct
6 Correct 12 ms 1280 KB Output is correct
7 Correct 21 ms 2304 KB Output is correct
8 Correct 20 ms 2304 KB Output is correct
9 Correct 13 ms 1284 KB Output is correct
10 Correct 12 ms 1284 KB Output is correct
11 Correct 24 ms 2304 KB Output is correct
12 Correct 24 ms 2304 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 14 ms 1280 KB Output is correct
15 Correct 19 ms 1792 KB Output is correct
16 Correct 19 ms 1792 KB Output is correct
17 Correct 32 ms 2048 KB Output is correct
18 Correct 22 ms 2048 KB Output is correct
19 Correct 23 ms 2168 KB Output is correct
20 Correct 34 ms 2176 KB Output is correct