답안 #157600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157600 2019-10-12T14:41:10 Z RoundMango 쌀 창고 (IOI11_ricehub) C++14
100 / 100
20 ms 2552 KB
#include <bits/stdc++.h>
using namespace std;
long long a[10000005], sum[10000005], n, l = 1, r, md, mx, xx, ans;
int besthub(int R, int L, int a[], long long b) {
	for (int i = 1; i <= R; i++) 
		sum[i] = sum[i-1] + a[i-1];
	r = R;
	while (l < r) {
		ans = b+1;
		md = (l+r+1)>>1;
		for (int i = md; i <= R; i++) {
			n = i-md+1;
			mx = (i+n+1)>>1;
			xx = sum[i] - sum[mx] - (i-mx)*a[mx-1] + a[mx-1]*(mx-n) - sum[mx-1] + sum[n-1];
			ans = min(ans, xx);
		}
	    if (ans <= b) l = md;
		else r = md-1;
	}
	return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 376 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 8 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 0 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 18 ms 1528 KB Output is correct
4 Correct 18 ms 1532 KB Output is correct
5 Correct 11 ms 1272 KB Output is correct
6 Correct 10 ms 1276 KB Output is correct
7 Correct 16 ms 2296 KB Output is correct
8 Correct 15 ms 2296 KB Output is correct
9 Correct 10 ms 1144 KB Output is correct
10 Correct 10 ms 1272 KB Output is correct
11 Correct 20 ms 2552 KB Output is correct
12 Correct 20 ms 2552 KB Output is correct
13 Correct 11 ms 1272 KB Output is correct
14 Correct 12 ms 1272 KB Output is correct
15 Correct 15 ms 2040 KB Output is correct
16 Correct 15 ms 2040 KB Output is correct
17 Correct 18 ms 2296 KB Output is correct
18 Correct 19 ms 2296 KB Output is correct
19 Correct 19 ms 2424 KB Output is correct
20 Correct 19 ms 2424 KB Output is correct