# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
787575 |
2023-07-19T09:51:09 Z |
bane |
Rice Hub (IOI11_ricehub) |
C++17 |
|
63 ms |
2260 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int x[], long long B)
{
vector<long long>X(R+1);
X[0] = -(long long)1e18;
for (int i = 1; i <= R; i++){
X[i] = x[i - 1];
}
int l = 1, r = R;
long long pf[R+1];
pf[0] = 0;
for (int i = 1; i<=R; i++){
pf[i] = pf[i - 1] + X[i];
}
function<bool(int)>check = [&](int mid){
int r = 0;
int l = 1;
while(r + 1 <= R){
++r;
while(r - l + 1 > mid){
++l;
}
long long avg = (pf[r] - pf[l - 1]) / mid;
if (r - l + 1 == mid){
int itt = upper_bound(X.begin(), X.end(), avg) - X.begin();
for (int it = itt - 20 ; it <= itt + 20; it++){
if (it < l || it > r)continue;
long long sum = 0;
if (it != l){
sum += (it - l) * X[it] - (pf[it-1] - pf[l-1]);
}
if (it != r){
sum += -(r - it) * X[it] + (pf[r] - pf[it]);
}
if (sum <= B)return true;
}
}
}
return false;
};
while(l<=r){
int mid = (l+r) / 2;
if (check(mid)){
l = mid + 1;
}else{
r = mid - 1;
}
}
return l - 1;
}
# |
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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 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 |
1 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 |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
264 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 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 |
# |
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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
4 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 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
596 KB |
Output is correct |
2 |
Correct |
26 ms |
596 KB |
Output is correct |
3 |
Correct |
10 ms |
2204 KB |
Output is correct |
4 |
Correct |
10 ms |
2260 KB |
Output is correct |
5 |
Correct |
54 ms |
1236 KB |
Output is correct |
6 |
Correct |
52 ms |
1236 KB |
Output is correct |
7 |
Correct |
9 ms |
2200 KB |
Output is correct |
8 |
Correct |
15 ms |
2260 KB |
Output is correct |
9 |
Correct |
47 ms |
1236 KB |
Output is correct |
10 |
Correct |
50 ms |
1236 KB |
Output is correct |
11 |
Correct |
13 ms |
2260 KB |
Output is correct |
12 |
Correct |
10 ms |
2260 KB |
Output is correct |
13 |
Correct |
63 ms |
1236 KB |
Output is correct |
14 |
Correct |
61 ms |
1236 KB |
Output is correct |
15 |
Correct |
8 ms |
1748 KB |
Output is correct |
16 |
Incorrect |
8 ms |
1748 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |