Submission #895794

# Submission time Handle Problem Language Result Execution time Memory
895794 2023-12-30T20:52:12 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
68 / 100
11 ms 3416 KB
#include <bits/stdc++.h>

using namespace std;

//#define int long long

#define ll long long

bool check(int mid, vector<ll>& psum, int *x, int money){
	for(int i = mid; i < (int)psum.size(); i++){
		ll val = x[i - mid/2];
		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] * (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];
	}
	int 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);
// }
# Verdict Execution time Memory Grader output
1 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 600 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 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 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 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 1 ms 344 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 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 400 KB Output is correct
21 Correct 1 ms 348 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 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Incorrect 11 ms 3416 KB Output isn't correct
4 Halted 0 ms 0 KB -