답안 #67564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67564 2018-08-15T01:44:24 Z Hoget157 쌀 창고 (IOI11_ricehub) C++14
100 / 100
44 ms 17280 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n,m,x[100010],b,l[100010] = {},r[100010] = {};

bool C(ll mid,ll num){
	ll A = num / 2,B = num - num / 2 - 1;
	ll mi = 1e+18;
	if(mid + A + 1 <= n && mid - B >= 0) mi = l[mid + A + 1] - l[mid + 1] - x[mid] * A + r[mid - B] - r[mid] - (m - x[mid]) * B;
	if(num % 2 == 0 && mid + B + 1 <= n && mid - A >= 0) mi = min(mi,l[mid + B + 1] - l[mid + 1] - x[mid] * B + r[mid - A] - r[mid] - (m - x[mid]) * A);
	return mi <= b;
}

int besthub(int R, int L, int X[], long long B){
	n = R,m = L,b = B;
	for(ll i = 0;i < n;i++) x[i] = X[i];
	ll ma = 0;
	for(ll i = 0;i < n;i++) l[i + 1] = l[i] + x[i];
	for(ll i = n - 1;i >= 0;i--) r[i] = r[i + 1] + L - x[i];
	for(ll i = 0;i < n;i++){
		ll low = 1,up = n + 1;
		while(up - low > 1){
			ll mid = (up + low) / 2;
			if(C(i,mid)) low = mid;
			else up = mid;
		}
		ma = max(ma,low);
		//for(int j = 1;j <= n;j++) C(i,j);
	}
	return ma;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 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 2 ms 616 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Correct 2 ms 676 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 3 ms 684 KB Output is correct
6 Correct 3 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 3 ms 696 KB Output is correct
9 Correct 2 ms 940 KB Output is correct
10 Correct 3 ms 940 KB Output is correct
11 Correct 2 ms 940 KB Output is correct
12 Correct 2 ms 940 KB Output is correct
13 Correct 3 ms 940 KB Output is correct
14 Correct 2 ms 940 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 940 KB Output is correct
20 Correct 2 ms 940 KB Output is correct
21 Correct 2 ms 940 KB Output is correct
22 Correct 3 ms 940 KB Output is correct
23 Correct 4 ms 940 KB Output is correct
24 Correct 3 ms 940 KB Output is correct
25 Correct 3 ms 940 KB Output is correct
26 Correct 2 ms 940 KB Output is correct
27 Correct 3 ms 940 KB Output is correct
28 Correct 3 ms 940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 940 KB Output is correct
2 Correct 2 ms 960 KB Output is correct
3 Correct 2 ms 960 KB Output is correct
4 Correct 2 ms 960 KB Output is correct
5 Correct 3 ms 960 KB Output is correct
6 Correct 3 ms 960 KB Output is correct
7 Correct 2 ms 996 KB Output is correct
8 Correct 3 ms 1020 KB Output is correct
9 Correct 3 ms 1020 KB Output is correct
10 Correct 2 ms 1020 KB Output is correct
11 Correct 2 ms 1020 KB Output is correct
12 Correct 2 ms 1020 KB Output is correct
13 Correct 3 ms 1020 KB Output is correct
14 Correct 2 ms 1020 KB Output is correct
15 Correct 2 ms 1020 KB Output is correct
16 Correct 3 ms 1020 KB Output is correct
17 Correct 3 ms 1020 KB Output is correct
18 Correct 2 ms 1020 KB Output is correct
19 Correct 3 ms 1020 KB Output is correct
20 Correct 3 ms 1024 KB Output is correct
21 Correct 4 ms 1160 KB Output is correct
22 Correct 4 ms 1160 KB Output is correct
23 Correct 3 ms 1244 KB Output is correct
24 Correct 7 ms 1244 KB Output is correct
25 Correct 4 ms 1288 KB Output is correct
26 Correct 4 ms 1288 KB Output is correct
27 Correct 4 ms 1376 KB Output is correct
28 Correct 4 ms 1376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1848 KB Output is correct
2 Correct 10 ms 1960 KB Output is correct
3 Correct 44 ms 5168 KB Output is correct
4 Correct 39 ms 6268 KB Output is correct
5 Correct 20 ms 6268 KB Output is correct
6 Correct 20 ms 6268 KB Output is correct
7 Correct 43 ms 7720 KB Output is correct
8 Correct 43 ms 8492 KB Output is correct
9 Correct 20 ms 8492 KB Output is correct
10 Correct 20 ms 8492 KB Output is correct
11 Correct 43 ms 10112 KB Output is correct
12 Correct 42 ms 11180 KB Output is correct
13 Correct 21 ms 11180 KB Output is correct
14 Correct 20 ms 11180 KB Output is correct
15 Correct 33 ms 12120 KB Output is correct
16 Correct 32 ms 12888 KB Output is correct
17 Correct 38 ms 14168 KB Output is correct
18 Correct 39 ms 15172 KB Output is correct
19 Correct 39 ms 16304 KB Output is correct
20 Correct 39 ms 17280 KB Output is correct