Submission #80561

# Submission time Handle Problem Language Result Execution time Memory
80561 2018-10-21T10:56:32 Z arman_ferdous Rice Hub (IOI11_ricehub) C++17
17 / 100
179 ms 5884 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

typedef long long ll;
const int N = 1e5+10;
int n; ll arr[N], sum[N], cap;

ll calc(int i, int j, ll x) {
	int p = lower_bound(arr,arr+n,x) - arr; p++;
	ll ret = x * (p - i) - (sum[p-1] - sum[i-1]);
	ret = ret + sum[j] - sum[p-1] - x * (j - p + 1);
	return ret;
}

bool can(int k) {
	for(int i = k; i <= n; i++) {
		ll med = (sum[i] - sum[i-k]) / k;
		for(ll m = med-3; m <= med+3; m++)
			if(calc(i-k+1,i,m) <= cap) return true;
	}
	return false;
}

int besthub(int R, int L, int X[], ll B) {
	n = R, cap = B; sum[0] = 0;
	for(int i = 0; i < R; i++) arr[i] = X[i];
	for(int i = 1; i <= R; i++) sum[i] = sum[i-1] + X[i-1];

	int lo = 1, hi = R, ret = 0;
	while(lo <= hi) {
		int mid = (lo + hi) >> 1;
		if(can(mid)) ret = mid, lo = mid+1;
		else hi = mid-1;
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 472 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 704 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 2 ms 716 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 2 ms 808 KB Output is correct
12 Correct 2 ms 808 KB Output is correct
13 Correct 2 ms 808 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 808 KB Output is correct
22 Correct 2 ms 816 KB Output is correct
23 Correct 2 ms 816 KB Output is correct
24 Correct 2 ms 816 KB Output is correct
25 Correct 3 ms 816 KB Output is correct
26 Correct 2 ms 816 KB Output is correct
27 Incorrect 3 ms 816 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 816 KB Output is correct
2 Correct 2 ms 816 KB Output is correct
3 Correct 2 ms 892 KB Output is correct
4 Correct 2 ms 892 KB Output is correct
5 Correct 2 ms 892 KB Output is correct
6 Correct 3 ms 892 KB Output is correct
7 Correct 3 ms 892 KB Output is correct
8 Correct 3 ms 892 KB Output is correct
9 Correct 2 ms 892 KB Output is correct
10 Correct 2 ms 892 KB Output is correct
11 Correct 3 ms 892 KB Output is correct
12 Correct 3 ms 892 KB Output is correct
13 Correct 2 ms 892 KB Output is correct
14 Correct 3 ms 892 KB Output is correct
15 Correct 3 ms 892 KB Output is correct
16 Correct 3 ms 892 KB Output is correct
17 Correct 2 ms 892 KB Output is correct
18 Correct 2 ms 892 KB Output is correct
19 Correct 2 ms 892 KB Output is correct
20 Correct 2 ms 892 KB Output is correct
21 Correct 8 ms 892 KB Output is correct
22 Correct 8 ms 1044 KB Output is correct
23 Correct 3 ms 1068 KB Output is correct
24 Correct 3 ms 1100 KB Output is correct
25 Correct 3 ms 1132 KB Output is correct
26 Correct 3 ms 1172 KB Output is correct
27 Incorrect 9 ms 1216 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 1636 KB Output is correct
2 Correct 82 ms 1788 KB Output is correct
3 Correct 21 ms 4340 KB Output is correct
4 Correct 18 ms 5444 KB Output is correct
5 Correct 141 ms 5444 KB Output is correct
6 Correct 140 ms 5444 KB Output is correct
7 Correct 16 ms 5884 KB Output is correct
8 Correct 15 ms 5884 KB Output is correct
9 Correct 127 ms 5884 KB Output is correct
10 Correct 148 ms 5884 KB Output is correct
11 Correct 19 ms 5884 KB Output is correct
12 Correct 19 ms 5884 KB Output is correct
13 Incorrect 179 ms 5884 KB Output isn't correct
14 Halted 0 ms 0 KB -