답안 #64621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64621 2018-08-05T05:12:53 Z gnoor 쌀 창고 (IOI11_ricehub) C++17
100 / 100
32 ms 16760 KB
#include "ricehub.h"

long long b;
long long pos[100100];
long long qs[100100];
int n;

bool work(int num) {
	int x=num/2;
	int hub;
	long long cur;
	for (int i=num;i<=n;i++) {
		hub=i-x;
		cur=qs[i]-qs[hub]-pos[hub]*x;
		cur+=pos[hub]*(num-x)-qs[hub]+qs[i-num];
		if (cur<=b) return true;
	}
	return false;
}

int besthub(int R, int L, int X[], long long B)
{
	b=B;
	n=R;
	for (int i=1;i<=n;i++) {
		qs[i]=pos[i]=X[i-1];
		qs[i]+=qs[i-1];
	}		

	int lo=1;
	int hi=R;
	int mid;
	while (lo<hi) {
		mid=(lo+hi+1)>>1;
		if (work(mid)) lo=mid;
		else hi=mid-1;
	}
	return lo;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 424 KB Output is correct
5 Correct 3 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 500 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 3 ms 692 KB Output is correct
5 Correct 2 ms 692 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 4 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 752 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 2 ms 792 KB Output is correct
19 Correct 3 ms 792 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 816 KB Output is correct
22 Correct 2 ms 820 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 3 ms 828 KB Output is correct
25 Correct 3 ms 832 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
27 Correct 3 ms 836 KB Output is correct
28 Correct 3 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 844 KB Output is correct
2 Correct 2 ms 844 KB Output is correct
3 Correct 3 ms 856 KB Output is correct
4 Correct 2 ms 864 KB Output is correct
5 Correct 2 ms 868 KB Output is correct
6 Correct 2 ms 892 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 3 ms 920 KB Output is correct
9 Correct 2 ms 944 KB Output is correct
10 Correct 3 ms 944 KB Output is correct
11 Correct 2 ms 944 KB Output is correct
12 Correct 3 ms 960 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 2 ms 976 KB Output is correct
15 Correct 2 ms 984 KB Output is correct
16 Correct 2 ms 988 KB Output is correct
17 Correct 2 ms 996 KB Output is correct
18 Correct 2 ms 1004 KB Output is correct
19 Correct 2 ms 1008 KB Output is correct
20 Correct 3 ms 1036 KB Output is correct
21 Correct 5 ms 1044 KB Output is correct
22 Correct 4 ms 1068 KB Output is correct
23 Correct 4 ms 1212 KB Output is correct
24 Correct 5 ms 1212 KB Output is correct
25 Correct 5 ms 1212 KB Output is correct
26 Correct 4 ms 1224 KB Output is correct
27 Correct 3 ms 1260 KB Output is correct
28 Correct 3 ms 1428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1828 KB Output is correct
2 Correct 7 ms 1964 KB Output is correct
3 Correct 27 ms 4532 KB Output is correct
4 Correct 28 ms 5596 KB Output is correct
5 Correct 14 ms 5596 KB Output is correct
6 Correct 20 ms 5596 KB Output is correct
7 Correct 17 ms 7064 KB Output is correct
8 Correct 21 ms 7852 KB Output is correct
9 Correct 14 ms 7852 KB Output is correct
10 Correct 11 ms 7852 KB Output is correct
11 Correct 24 ms 9460 KB Output is correct
12 Correct 32 ms 10528 KB Output is correct
13 Correct 11 ms 10528 KB Output is correct
14 Correct 14 ms 10528 KB Output is correct
15 Correct 20 ms 11600 KB Output is correct
16 Correct 27 ms 12388 KB Output is correct
17 Correct 27 ms 13560 KB Output is correct
18 Correct 22 ms 14520 KB Output is correct
19 Correct 19 ms 15720 KB Output is correct
20 Correct 21 ms 16760 KB Output is correct