답안 #600233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600233 2022-07-20T14:40:40 Z _Avocado_ 쌀 창고 (IOI11_ricehub) C++14
42 / 100
14 ms 2136 KB
#include <bits/stdc++.h>
#include "ricehub.h"
//#define int int64_t
using namespace std;

int min(int a, int b){
	if(a < b) return a;
	return b;
}

int bsearch(int n, int len, vector<int>&fred, vector<long long>&prefix, long long budget){
	int l = -1;
	int r = n+1;
	
	while(r-l > 1){
		int m = (r+l)/2;
		int ans = 1e9;
		int mid = m/2+1;
		for(int i = m; i<=n; ++i){
			int hub = fred[mid];
			long long one = ((m/2) * hub)-(prefix[mid-1]-prefix[i-m]);
			long long two = (prefix[i]-prefix[mid-(1-m%2)]) - ((m/2)*hub);
			++mid;
			ans = min(ans, one+two);
		}
		if(ans <= budget) l = m;
		else r = m;

	}
	return l;
}
			

int besthub(int R, int L, int X[], long long B){
	int n = R;
	int len = L;
	long long budget = B;
	vector<long long>prefix(n+1);
	for(int i = 1; i<=n; ++i){
		prefix[i] = prefix[i-1] + X[i-1];
	}
	
	vector<int>fred;
	fred.push_back(0);
	for(int i = 0; i<n; ++i) fred.push_back(X[i]);
	
	return bsearch(n, len, fred, prefix, budget);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 224 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Incorrect 1 ms 340 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 14 ms 2136 KB Output is correct
4 Incorrect 13 ms 2128 KB Output isn't correct
5 Halted 0 ms 0 KB -