Submission #20806

# Submission time Handle Problem Language Result Execution time Memory
20806 2017-02-16T08:15:39 Z jjwdi0 Rice Hub (IOI11_ricehub) C++11
100 / 100
23 ms 5680 KB
#include "ricehub.h"
#define MAX_N 100005
typedef long long ll;

int max(int X, int Y){return X>Y?X:Y;}
int besthub(int R, int L, int X[], ll B) {
	int ans = 0;
	int i = 1, j = 1;
	ll cnt = 0LL, A[MAX_N];
	for(int i=R-1; i>=0; i--) X[i+1] = X[i];
	A[0] = 0LL;
	for(int i=1; i<=R; i++) A[i] = A[i-1] + X[i];
	while(i <= R && j <= R) {
		int mid = i + j >> 1;
		while(X[(i+j)/2] * (ll)((i+j)/2 - i + 1) - (A[(i+j)/2] - A[i-1]) + A[j] - X[(i+j)/2] * (ll)(j - (i+j)/2 + 1) - A[(i+j)/2 - 1] > B && i < j) i++;
		ans = max(ans, j - i + 1);
		j++;
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:14:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = i + j >> 1;
               ^
ricehub.cpp:14:7: warning: unused variable 'mid' [-Wunused-variable]
   int mid = i + j >> 1;
       ^
ricehub.cpp:9:5: warning: unused variable 'cnt' [-Wunused-variable]
  ll cnt = 0LL, A[MAX_N];
     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5676 KB Output is correct
2 Correct 0 ms 5676 KB Output is correct
3 Correct 0 ms 5676 KB Output is correct
4 Correct 0 ms 5676 KB Output is correct
5 Correct 0 ms 5680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5680 KB Output is correct
2 Correct 0 ms 5672 KB Output is correct
3 Correct 0 ms 5680 KB Output is correct
4 Correct 0 ms 5676 KB Output is correct
5 Correct 0 ms 5680 KB Output is correct
6 Correct 0 ms 5676 KB Output is correct
7 Correct 0 ms 5676 KB Output is correct
8 Correct 0 ms 5672 KB Output is correct
9 Correct 0 ms 5672 KB Output is correct
10 Correct 0 ms 5676 KB Output is correct
11 Correct 0 ms 5676 KB Output is correct
12 Correct 0 ms 5676 KB Output is correct
13 Correct 0 ms 5680 KB Output is correct
14 Correct 0 ms 5672 KB Output is correct
15 Correct 0 ms 5676 KB Output is correct
16 Correct 0 ms 5680 KB Output is correct
17 Correct 0 ms 5672 KB Output is correct
18 Correct 0 ms 5676 KB Output is correct
19 Correct 0 ms 5672 KB Output is correct
20 Correct 0 ms 5680 KB Output is correct
21 Correct 0 ms 5676 KB Output is correct
22 Correct 0 ms 5676 KB Output is correct
23 Correct 0 ms 5672 KB Output is correct
24 Correct 0 ms 5672 KB Output is correct
25 Correct 0 ms 5676 KB Output is correct
26 Correct 0 ms 5676 KB Output is correct
27 Correct 0 ms 5676 KB Output is correct
28 Correct 0 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5672 KB Output is correct
2 Correct 0 ms 5676 KB Output is correct
3 Correct 0 ms 5672 KB Output is correct
4 Correct 0 ms 5680 KB Output is correct
5 Correct 0 ms 5672 KB Output is correct
6 Correct 0 ms 5676 KB Output is correct
7 Correct 0 ms 5672 KB Output is correct
8 Correct 0 ms 5672 KB Output is correct
9 Correct 0 ms 5676 KB Output is correct
10 Correct 0 ms 5676 KB Output is correct
11 Correct 0 ms 5672 KB Output is correct
12 Correct 0 ms 5676 KB Output is correct
13 Correct 0 ms 5672 KB Output is correct
14 Correct 0 ms 5676 KB Output is correct
15 Correct 0 ms 5676 KB Output is correct
16 Correct 0 ms 5676 KB Output is correct
17 Correct 0 ms 5676 KB Output is correct
18 Correct 0 ms 5672 KB Output is correct
19 Correct 0 ms 5680 KB Output is correct
20 Correct 0 ms 5676 KB Output is correct
21 Correct 0 ms 5672 KB Output is correct
22 Correct 0 ms 5676 KB Output is correct
23 Correct 0 ms 5680 KB Output is correct
24 Correct 0 ms 5676 KB Output is correct
25 Correct 0 ms 5672 KB Output is correct
26 Correct 0 ms 5680 KB Output is correct
27 Correct 0 ms 5676 KB Output is correct
28 Correct 0 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5676 KB Output is correct
2 Correct 3 ms 5680 KB Output is correct
3 Correct 16 ms 5676 KB Output is correct
4 Correct 23 ms 5672 KB Output is correct
5 Correct 9 ms 5672 KB Output is correct
6 Correct 6 ms 5672 KB Output is correct
7 Correct 13 ms 5680 KB Output is correct
8 Correct 16 ms 5676 KB Output is correct
9 Correct 6 ms 5672 KB Output is correct
10 Correct 3 ms 5676 KB Output is correct
11 Correct 13 ms 5680 KB Output is correct
12 Correct 19 ms 5676 KB Output is correct
13 Correct 6 ms 5680 KB Output is correct
14 Correct 6 ms 5676 KB Output is correct
15 Correct 16 ms 5680 KB Output is correct
16 Correct 13 ms 5676 KB Output is correct
17 Correct 13 ms 5676 KB Output is correct
18 Correct 9 ms 5676 KB Output is correct
19 Correct 19 ms 5676 KB Output is correct
20 Correct 16 ms 5676 KB Output is correct