답안 #71490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71490 2018-08-24T23:04:22 Z RezwanArefin01 쌀 창고 (IOI11_ricehub) C++17
100 / 100
25 ms 16132 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 1e5 + 10;

ll y[N]; 
int besthub(int n, int L, int x[], ll B) {
	y[0] = x[0]; 
	for(int i = 1; i < n; i++) {
		y[i] = y[i - 1] + x[i]; 
	}
	auto cost = [&x](int l, int r) {
		int m = l + r >> 1; 
		ll a = (ll) x[m] * (m - l + 1); 
		a -= y[m]; 
		if(l) a += y[l - 1]; 

		ll b = y[r] - y[m] - (r - m) * 1ll * x[m]; 
		return a + b; 
	};
	int l = 0, r = 0;
	int ans = 0; 
	while(l < n) {
		while(r < n && cost(l, r) <= B) r++; 
		ans = max(ans, r - l);
		l++;
	} return ans; 
}

Compilation message

ricehub.cpp: In lambda function:
ricehub.cpp:16:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1; 
           ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Correct 3 ms 656 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 2 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 836 KB Output is correct
2 Correct 3 ms 936 KB Output is correct
3 Correct 3 ms 936 KB Output is correct
4 Correct 2 ms 936 KB Output is correct
5 Correct 2 ms 936 KB Output is correct
6 Correct 3 ms 936 KB Output is correct
7 Correct 2 ms 936 KB Output is correct
8 Correct 3 ms 936 KB Output is correct
9 Correct 2 ms 1004 KB Output is correct
10 Correct 2 ms 1004 KB Output is correct
11 Correct 2 ms 1004 KB Output is correct
12 Correct 2 ms 1024 KB Output is correct
13 Correct 2 ms 1024 KB Output is correct
14 Correct 2 ms 1024 KB Output is correct
15 Correct 2 ms 1024 KB Output is correct
16 Correct 3 ms 1024 KB Output is correct
17 Correct 3 ms 1024 KB Output is correct
18 Correct 2 ms 1024 KB Output is correct
19 Correct 2 ms 1044 KB Output is correct
20 Correct 2 ms 1044 KB Output is correct
21 Correct 3 ms 1044 KB Output is correct
22 Correct 2 ms 1044 KB Output is correct
23 Correct 3 ms 1188 KB Output is correct
24 Correct 3 ms 1188 KB Output is correct
25 Correct 3 ms 1188 KB Output is correct
26 Correct 3 ms 1188 KB Output is correct
27 Correct 3 ms 1188 KB Output is correct
28 Correct 2 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1188 KB Output is correct
2 Correct 2 ms 1188 KB Output is correct
3 Correct 2 ms 1188 KB Output is correct
4 Correct 3 ms 1188 KB Output is correct
5 Correct 2 ms 1188 KB Output is correct
6 Correct 2 ms 1188 KB Output is correct
7 Correct 2 ms 1188 KB Output is correct
8 Correct 3 ms 1188 KB Output is correct
9 Correct 3 ms 1188 KB Output is correct
10 Correct 3 ms 1188 KB Output is correct
11 Correct 4 ms 1188 KB Output is correct
12 Correct 4 ms 1188 KB Output is correct
13 Correct 3 ms 1208 KB Output is correct
14 Correct 3 ms 1208 KB Output is correct
15 Correct 3 ms 1208 KB Output is correct
16 Correct 2 ms 1240 KB Output is correct
17 Correct 3 ms 1240 KB Output is correct
18 Correct 3 ms 1240 KB Output is correct
19 Correct 2 ms 1240 KB Output is correct
20 Correct 2 ms 1240 KB Output is correct
21 Correct 4 ms 1240 KB Output is correct
22 Correct 3 ms 1240 KB Output is correct
23 Correct 4 ms 1276 KB Output is correct
24 Correct 3 ms 1308 KB Output is correct
25 Correct 4 ms 1340 KB Output is correct
26 Correct 3 ms 1404 KB Output is correct
27 Correct 4 ms 1444 KB Output is correct
28 Correct 3 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1756 KB Output is correct
2 Correct 4 ms 1892 KB Output is correct
3 Correct 21 ms 3956 KB Output is correct
4 Correct 19 ms 5008 KB Output is correct
5 Correct 9 ms 5008 KB Output is correct
6 Correct 9 ms 5064 KB Output is correct
7 Correct 17 ms 6496 KB Output is correct
8 Correct 16 ms 7192 KB Output is correct
9 Correct 10 ms 7192 KB Output is correct
10 Correct 9 ms 7192 KB Output is correct
11 Correct 22 ms 8872 KB Output is correct
12 Correct 25 ms 9936 KB Output is correct
13 Correct 11 ms 9936 KB Output is correct
14 Correct 16 ms 10108 KB Output is correct
15 Correct 19 ms 11180 KB Output is correct
16 Correct 20 ms 12100 KB Output is correct
17 Correct 21 ms 13164 KB Output is correct
18 Correct 19 ms 14160 KB Output is correct
19 Correct 19 ms 15240 KB Output is correct
20 Correct 23 ms 16132 KB Output is correct