답안 #70751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70751 2018-08-23T09:47:30 Z MrTEK 쌀 창고 (IOI11_ricehub) C++14
100 / 100
49 ms 16144 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define N 100005
using namespace std;

int n,ar[N],ans;
long long b,pre[N];

bool check(int l,int r) {
	long long sum = 0;
	int mid = (l + r) / 2;
	sum = 1ll * ar[mid] * (mid - l + 1) - (pre[mid] - pre[l - 1]);
	sum += (pre[r] - pre[mid - 1]) - (1ll * ar[mid] * (r - mid + 1)); 
	return sum <= b;
}

int besthub(int R, int L, int X[], long long B) {
	n = R;
	b = B;
	for (int i = 1 ; i <= n ; i++)
		ar[i] = X[i - 1];
	for (int i = 1 ; i <= n ; i++) 
		pre[i] = pre[i - 1] + ar[i];
	for (int i = 1  ; i <= n ; i++) {
		int l = i, r = n;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (check(i,mid)) l = mid + 1;
			else r = mid - 1; 
		}
		ans = max(ans,l - i);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 656 KB Output is correct
2 Correct 3 ms 656 KB Output is correct
3 Correct 3 ms 656 KB Output is correct
4 Correct 2 ms 656 KB Output is correct
5 Correct 2 ms 656 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
9 Correct 3 ms 656 KB Output is correct
10 Correct 4 ms 656 KB Output is correct
11 Correct 2 ms 668 KB Output is correct
12 Correct 3 ms 668 KB Output is correct
13 Correct 3 ms 676 KB Output is correct
14 Correct 3 ms 680 KB Output is correct
15 Correct 3 ms 684 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 3 ms 692 KB Output is correct
18 Correct 5 ms 692 KB Output is correct
19 Correct 4 ms 700 KB Output is correct
20 Correct 3 ms 832 KB Output is correct
21 Correct 3 ms 832 KB Output is correct
22 Correct 3 ms 832 KB Output is correct
23 Correct 4 ms 832 KB Output is correct
24 Correct 5 ms 832 KB Output is correct
25 Correct 3 ms 832 KB Output is correct
26 Correct 3 ms 832 KB Output is correct
27 Correct 3 ms 832 KB Output is correct
28 Correct 3 ms 832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 832 KB Output is correct
2 Correct 2 ms 832 KB Output is correct
3 Correct 4 ms 832 KB Output is correct
4 Correct 4 ms 832 KB Output is correct
5 Correct 3 ms 832 KB Output is correct
6 Correct 2 ms 892 KB Output is correct
7 Correct 2 ms 892 KB Output is correct
8 Correct 4 ms 892 KB Output is correct
9 Correct 2 ms 892 KB Output is correct
10 Correct 3 ms 892 KB Output is correct
11 Correct 3 ms 892 KB Output is correct
12 Correct 2 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 2 ms 940 KB Output is correct
16 Correct 2 ms 940 KB Output is correct
17 Correct 3 ms 940 KB Output is correct
18 Correct 2 ms 940 KB Output is correct
19 Correct 3 ms 972 KB Output is correct
20 Correct 3 ms 972 KB Output is correct
21 Correct 4 ms 972 KB Output is correct
22 Correct 5 ms 972 KB Output is correct
23 Correct 4 ms 972 KB Output is correct
24 Correct 3 ms 972 KB Output is correct
25 Correct 4 ms 1008 KB Output is correct
26 Correct 4 ms 1036 KB Output is correct
27 Correct 5 ms 1116 KB Output is correct
28 Correct 4 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1532 KB Output is correct
2 Correct 7 ms 1660 KB Output is correct
3 Correct 42 ms 3952 KB Output is correct
4 Correct 38 ms 5040 KB Output is correct
5 Correct 18 ms 5040 KB Output is correct
6 Correct 18 ms 5040 KB Output is correct
7 Correct 32 ms 6648 KB Output is correct
8 Correct 33 ms 7264 KB Output is correct
9 Correct 18 ms 7264 KB Output is correct
10 Correct 14 ms 7264 KB Output is correct
11 Correct 39 ms 8896 KB Output is correct
12 Correct 42 ms 9960 KB Output is correct
13 Correct 19 ms 9960 KB Output is correct
14 Correct 25 ms 10060 KB Output is correct
15 Correct 30 ms 11220 KB Output is correct
16 Correct 30 ms 11948 KB Output is correct
17 Correct 36 ms 13312 KB Output is correct
18 Correct 49 ms 14160 KB Output is correct
19 Correct 30 ms 15104 KB Output is correct
20 Correct 35 ms 16144 KB Output is correct