Submission #58318

# Submission time Handle Problem Language Result Execution time Memory
58318 2018-07-17T13:33:46 Z PeppaPig Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 1008 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3 + 5;

long long sum[N];

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 = 1;
	int l = 2, 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 == 2) ret = min(ret, sum[i + 1] - 2 * sum[i] + sum[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 + sum[i + m]);
			}
		}
		if(ret <= B) res = mid, l = mid + 1;
		else r = mid - 1;
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 496 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 672 KB Output is correct
2 Correct 2 ms 688 KB Output is correct
3 Correct 3 ms 688 KB Output is correct
4 Incorrect 2 ms 688 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1008 KB Output isn't correct
2 Halted 0 ms 0 KB -