답안 #895796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895796 2023-12-30T20:56:44 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
100 / 100
10 ms 3436 KB
#include <bits/stdc++.h>

using namespace std;

//#define int long long

#define ll long long

bool check(ll mid, vector<ll>& psum, int *x, ll money){
	for(int i = mid; i < (int)psum.size(); i++){
		ll val = x[i - mid/2 - 1];
		val *= (mid - mid/2);
		ll tot = val - (psum[i - mid/2] - psum[i - mid]);
		tot += (psum[i] - psum[i - mid/2]) - (x[i-mid/2 - 1] * (mid/2));
		if(tot <= money){
			return true;
		}
	}
	return false;
}

int besthub(int r, int l, int x[], long long b){
	vector<ll> psum(r+1);
	psum[0] = 0;
	for(int i = 1; i <= r; i++){
		psum[i] = psum[i-1] + x[i-1];
	}
	ll left = 0, right = r, mid;
	while(left < right){
		mid = (left + right + 1)/2;
		if(check(mid, psum, x, b)){
			left = mid;
		}else{
			right = mid-1;
		}
	}
	return left;
}

// signed main(){
// 	ios_base::sync_with_stdio(0); cin.tie(0);
// 	vector<int> v;
// 	v.push_back(1); v.push_back(2); v.push_back(10); v.push_back(12); v.push_back(14);
// 	cout << besthub(5, 20, v, 6);
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 9 ms 3420 KB Output is correct
4 Correct 9 ms 3388 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 2908 KB Output is correct
7 Correct 8 ms 3420 KB Output is correct
8 Correct 8 ms 3436 KB Output is correct
9 Correct 5 ms 2904 KB Output is correct
10 Correct 5 ms 2908 KB Output is correct
11 Correct 10 ms 3364 KB Output is correct
12 Correct 10 ms 3416 KB Output is correct
13 Correct 6 ms 2904 KB Output is correct
14 Correct 5 ms 2908 KB Output is correct
15 Correct 7 ms 3164 KB Output is correct
16 Correct 7 ms 3028 KB Output is correct
17 Correct 8 ms 3164 KB Output is correct
18 Correct 8 ms 3360 KB Output is correct
19 Correct 9 ms 3420 KB Output is correct
20 Correct 9 ms 3412 KB Output is correct