Submission #121026

# Submission time Handle Problem Language Result Execution time Memory
121026 2019-06-26T03:13:42 Z turbat Rice Hub (IOI11_ricehub) C++14
100 / 100
47 ms 2552 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

long long s[100005];

long long can(int l, int r){
	int mid = (l + r) / 2;
	if ((r - l) % 2 == 0) return s[r] + s[l - 1] - s[mid] - s[mid - 1];		
	return s[r] + s[l - 1] - 2 * s[mid];
}

int besthub(int R, int L, int X[], long long B){
	int ans = 0;
	for (int i = 1;i <= R;i++) s[i] = s[i - 1] + X[i - 1];
	for (int i = 1;i <= R;i++){
		int l = i, r = R, mid;
		while (l != r){
			mid = (l + r + 1) / 2;
			if (can(i, mid) <= B) l = mid;
			else r = mid - 1;
		}
		ans = max(ans, l - i + 1);
	}
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 424 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 4 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Correct 27 ms 2552 KB Output is correct
4 Correct 26 ms 2552 KB Output is correct
5 Correct 13 ms 1400 KB Output is correct
6 Correct 13 ms 1272 KB Output is correct
7 Correct 24 ms 2304 KB Output is correct
8 Correct 25 ms 2372 KB Output is correct
9 Correct 13 ms 1152 KB Output is correct
10 Correct 13 ms 1280 KB Output is correct
11 Correct 28 ms 2552 KB Output is correct
12 Correct 47 ms 2524 KB Output is correct
13 Correct 14 ms 1356 KB Output is correct
14 Correct 14 ms 1280 KB Output is correct
15 Correct 20 ms 2048 KB Output is correct
16 Correct 22 ms 2040 KB Output is correct
17 Correct 25 ms 2304 KB Output is correct
18 Correct 25 ms 2472 KB Output is correct
19 Correct 26 ms 2432 KB Output is correct
20 Correct 27 ms 2432 KB Output is correct