Submission #655640

# Submission time Handle Problem Language Result Execution time Memory
655640 2022-11-05T04:13:14 Z horiseun Rice Hub (IOI11_ricehub) C++11
100 / 100
16 ms 1868 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
 
#define ll long long

vector<ll> pref;
 
ll calc(int length, int x[], int r) {
	ll val = LLONG_MAX;
	for (int i = length - 1; i < r; i++) {
		int start = i - length + 1;
		int pos = (i + i - length + 1) / 2;
		val = min(val, (pos - start) * x[pos] - (pref[pos] - pref[start]) + (pref[i + 1] - pref[pos + 1]) - (i - pos) * x[pos]);
	}
	return val;
}
 
int besthub(int r, int l, int x[], ll b) {
	pref.push_back(0);
	for (int i = 0; i < r; i++) {
		pref.push_back(pref[i] + x[i]);
	}
 
	int low = 0, upp = r + 1;
	while (low + 1 != upp) {
		int mid = (low + upp) / 2;
		if (calc(mid, x, r) <= b) low = mid;
		else upp = mid;
	}
    return low;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 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 1 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 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 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 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 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 0 ms 212 KB Output is correct
9 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 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 1 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 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 10 ms 1868 KB Output is correct
4 Correct 16 ms 1780 KB Output is correct
5 Correct 7 ms 1104 KB Output is correct
6 Correct 7 ms 1128 KB Output is correct
7 Correct 10 ms 1868 KB Output is correct
8 Correct 15 ms 1800 KB Output is correct
9 Correct 9 ms 1104 KB Output is correct
10 Correct 8 ms 1104 KB Output is correct
11 Correct 12 ms 1828 KB Output is correct
12 Correct 11 ms 1868 KB Output is correct
13 Correct 7 ms 1104 KB Output is correct
14 Correct 7 ms 1104 KB Output is correct
15 Correct 8 ms 1740 KB Output is correct
16 Correct 9 ms 1740 KB Output is correct
17 Correct 10 ms 1740 KB Output is correct
18 Correct 10 ms 1740 KB Output is correct
19 Correct 15 ms 1796 KB Output is correct
20 Correct 11 ms 1740 KB Output is correct