Submission #13485

# Submission time Handle Problem Language Result Execution time Memory
13485 2015-02-21T21:53:15 Z ainta Rice Hub (IOI11_ricehub) C++
100 / 100
23 ms 4988 KB
#include "ricehub.h"

int besthub(int R, int L, int X[], long long B)
{
	int i, be, ed, t, Res = 0;
	long long S = 0;
	for (i = 0; i < R; i++){
		if (i == 0)be = 0, ed = 0, S = 0;
		if (ed < i)be = ed = i, S = 0;
		t = i * 2 - ed - 2;
		if (be == t){
			S -= (X[i] - X[be]);
			be++;
		}
		t = i * 2 - ed - 1;
		if (be == t){
			S -= (X[i] - X[be]);
			be++;
		}
		while (be - 1 >= 0 && ed + 1 < R){
			if (S + X[ed + 1] - X[be - 1] > B)break;
			S += X[ed + 1] - X[be - 1];
			be--, ed++;
		}
		if (ed + 1 < R && S + X[ed + 1] - X[i]<= B){
			S += X[ed + 1] - X[i];
			ed++;
		}
		if (Res < ed - be + 1)Res = ed - be + 1;
		if (i != R - 1 && be + ed == i * 2){
			S += X[i + 1] - X[i];
		}
	}
	return Res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4988 KB Output is correct
2 Correct 0 ms 4988 KB Output is correct
3 Correct 0 ms 4988 KB Output is correct
4 Correct 0 ms 4988 KB Output is correct
5 Correct 0 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4988 KB Output is correct
2 Correct 0 ms 4988 KB Output is correct
3 Correct 0 ms 4988 KB Output is correct
4 Correct 0 ms 4988 KB Output is correct
5 Correct 0 ms 4988 KB Output is correct
6 Correct 0 ms 4988 KB Output is correct
7 Correct 0 ms 4988 KB Output is correct
8 Correct 0 ms 4988 KB Output is correct
9 Correct 0 ms 4988 KB Output is correct
10 Correct 0 ms 4988 KB Output is correct
11 Correct 0 ms 4988 KB Output is correct
12 Correct 0 ms 4988 KB Output is correct
13 Correct 0 ms 4988 KB Output is correct
14 Correct 0 ms 4988 KB Output is correct
15 Correct 0 ms 4988 KB Output is correct
16 Correct 0 ms 4988 KB Output is correct
17 Correct 0 ms 4988 KB Output is correct
18 Correct 0 ms 4988 KB Output is correct
19 Correct 0 ms 4988 KB Output is correct
20 Correct 0 ms 4988 KB Output is correct
21 Correct 0 ms 4988 KB Output is correct
22 Correct 0 ms 4988 KB Output is correct
23 Correct 0 ms 4988 KB Output is correct
24 Correct 0 ms 4988 KB Output is correct
25 Correct 0 ms 4988 KB Output is correct
26 Correct 0 ms 4988 KB Output is correct
27 Correct 0 ms 4988 KB Output is correct
28 Correct 0 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4988 KB Output is correct
2 Correct 0 ms 4988 KB Output is correct
3 Correct 0 ms 4988 KB Output is correct
4 Correct 0 ms 4988 KB Output is correct
5 Correct 0 ms 4988 KB Output is correct
6 Correct 0 ms 4988 KB Output is correct
7 Correct 0 ms 4988 KB Output is correct
8 Correct 0 ms 4988 KB Output is correct
9 Correct 0 ms 4988 KB Output is correct
10 Correct 0 ms 4988 KB Output is correct
11 Correct 0 ms 4988 KB Output is correct
12 Correct 0 ms 4988 KB Output is correct
13 Correct 0 ms 4988 KB Output is correct
14 Correct 0 ms 4988 KB Output is correct
15 Correct 0 ms 4988 KB Output is correct
16 Correct 0 ms 4988 KB Output is correct
17 Correct 0 ms 4988 KB Output is correct
18 Correct 0 ms 4988 KB Output is correct
19 Correct 0 ms 4988 KB Output is correct
20 Correct 0 ms 4988 KB Output is correct
21 Correct 0 ms 4988 KB Output is correct
22 Correct 1 ms 4988 KB Output is correct
23 Correct 0 ms 4988 KB Output is correct
24 Correct 1 ms 4988 KB Output is correct
25 Correct 0 ms 4988 KB Output is correct
26 Correct 0 ms 4988 KB Output is correct
27 Correct 0 ms 4988 KB Output is correct
28 Correct 0 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4988 KB Output is correct
2 Correct 3 ms 4988 KB Output is correct
3 Correct 0 ms 4988 KB Output is correct
4 Correct 17 ms 4988 KB Output is correct
5 Correct 0 ms 4988 KB Output is correct
6 Correct 10 ms 4988 KB Output is correct
7 Correct 8 ms 4988 KB Output is correct
8 Correct 9 ms 4988 KB Output is correct
9 Correct 0 ms 4988 KB Output is correct
10 Correct 9 ms 4988 KB Output is correct
11 Correct 15 ms 4988 KB Output is correct
12 Correct 8 ms 4988 KB Output is correct
13 Correct 5 ms 4988 KB Output is correct
14 Correct 0 ms 4988 KB Output is correct
15 Correct 9 ms 4988 KB Output is correct
16 Correct 0 ms 4988 KB Output is correct
17 Correct 0 ms 4988 KB Output is correct
18 Correct 22 ms 4988 KB Output is correct
19 Correct 0 ms 4988 KB Output is correct
20 Correct 23 ms 4988 KB Output is correct