Submission #58343

# Submission time Handle Problem Language Result Execution time Memory
58343 2018-07-17T13:56:05 Z PeppaPig Rice Hub (IOI11_ricehub) C++14
68 / 100
6 ms 764 KB
//#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3 + 5;

long long sum[N];

long long min(long long a, int b) { return a < b ? a : b; }

int besthub(int R, int L, int X[], long long B)
{
	for(int i = 1; i <= R; i++) sum[i] = sum[i - 1] + X[i - 1];
	int res = 0;
	int l = 0, r = R;
	while(l <= r) {
		int mid = (l + r) >> 1;
		int m = mid >> 1;
		long long ret = LLONG_MAX;
		for(int i = 1; i <= R - mid + 1; i++) {
			if(mid == 1) ret = min(ret, 0);
			if(mid == 2) ret = min(ret, X[i] - X[i - 1]);
			else {
				long long t = sum[i + mid - 1] - sum[i + m] - sum[i + m - 1] + sum[i - 1];
				if(mid & 1) ret = min(ret, t);
				else ret = min(ret, t + X[i + m - 1]);
			}
		}
		if(ret <= B) res = mid, l = mid + 1;
		else r = mid - 1;
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 660 KB Output is correct
2 Correct 3 ms 660 KB Output is correct
3 Correct 3 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 3 ms 660 KB Output is correct
7 Correct 3 ms 660 KB Output is correct
8 Correct 3 ms 660 KB Output is correct
9 Correct 3 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 5 ms 660 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 660 KB Output is correct
14 Correct 2 ms 660 KB Output is correct
15 Correct 3 ms 660 KB Output is correct
16 Correct 2 ms 660 KB Output is correct
17 Correct 3 ms 660 KB Output is correct
18 Correct 2 ms 660 KB Output is correct
19 Correct 2 ms 660 KB Output is correct
20 Correct 3 ms 660 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 2 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 2 ms 744 KB Output is correct
25 Correct 2 ms 744 KB Output is correct
26 Correct 2 ms 744 KB Output is correct
27 Correct 2 ms 744 KB Output is correct
28 Correct 3 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 3 ms 744 KB Output is correct
3 Correct 3 ms 744 KB Output is correct
4 Correct 2 ms 744 KB Output is correct
5 Correct 2 ms 744 KB Output is correct
6 Correct 3 ms 744 KB Output is correct
7 Correct 4 ms 744 KB Output is correct
8 Correct 3 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 2 ms 744 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 2 ms 744 KB Output is correct
17 Correct 3 ms 744 KB Output is correct
18 Correct 2 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 4 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 3 ms 752 KB Output is correct
24 Correct 3 ms 752 KB Output is correct
25 Correct 4 ms 752 KB Output is correct
26 Correct 3 ms 752 KB Output is correct
27 Correct 3 ms 752 KB Output is correct
28 Correct 3 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -