#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ab(ll x){
return max(x, -x);
}
int besthub(int n, int L, int X[], ll B){
int l = 1, r = n + 1;
int k;
bool ok;
int med;
ll sum = 0;
while(l + 1 < r){
k = (l + r)/2;
ok = false;
for(int i = 0;i <= n-k;i ++ ){
med = k / 2;
sum = 0;
for(int j = 0;j < k;j ++ ){
sum += ab(X[i + j] - X[i + med]);
}
if(sum <= B)
ok = true;
}
if(ok)
l = k;
else
r = k;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
516 KB |
Output is correct |
4 |
Correct |
3 ms |
516 KB |
Output is correct |
5 |
Correct |
4 ms |
516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
516 KB |
Output is correct |
2 |
Correct |
2 ms |
516 KB |
Output is correct |
3 |
Correct |
4 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
548 KB |
Output is correct |
5 |
Correct |
3 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
548 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
3 ms |
612 KB |
Output is correct |
10 |
Correct |
3 ms |
612 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
3 ms |
620 KB |
Output is correct |
14 |
Correct |
4 ms |
620 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
3 ms |
620 KB |
Output is correct |
17 |
Correct |
4 ms |
620 KB |
Output is correct |
18 |
Correct |
3 ms |
620 KB |
Output is correct |
19 |
Correct |
3 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
4 ms |
796 KB |
Output is correct |
22 |
Correct |
4 ms |
796 KB |
Output is correct |
23 |
Correct |
3 ms |
796 KB |
Output is correct |
24 |
Correct |
3 ms |
796 KB |
Output is correct |
25 |
Correct |
3 ms |
840 KB |
Output is correct |
26 |
Correct |
3 ms |
840 KB |
Output is correct |
27 |
Correct |
3 ms |
840 KB |
Output is correct |
28 |
Correct |
5 ms |
840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
840 KB |
Output is correct |
2 |
Correct |
3 ms |
840 KB |
Output is correct |
3 |
Correct |
4 ms |
840 KB |
Output is correct |
4 |
Correct |
3 ms |
840 KB |
Output is correct |
5 |
Correct |
3 ms |
840 KB |
Output is correct |
6 |
Correct |
3 ms |
840 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
4 ms |
840 KB |
Output is correct |
9 |
Correct |
3 ms |
840 KB |
Output is correct |
10 |
Correct |
3 ms |
840 KB |
Output is correct |
11 |
Correct |
4 ms |
840 KB |
Output is correct |
12 |
Correct |
4 ms |
840 KB |
Output is correct |
13 |
Correct |
4 ms |
840 KB |
Output is correct |
14 |
Correct |
3 ms |
840 KB |
Output is correct |
15 |
Correct |
3 ms |
840 KB |
Output is correct |
16 |
Correct |
4 ms |
840 KB |
Output is correct |
17 |
Correct |
3 ms |
840 KB |
Output is correct |
18 |
Correct |
4 ms |
840 KB |
Output is correct |
19 |
Correct |
4 ms |
840 KB |
Output is correct |
20 |
Correct |
4 ms |
840 KB |
Output is correct |
21 |
Correct |
33 ms |
840 KB |
Output is correct |
22 |
Correct |
34 ms |
984 KB |
Output is correct |
23 |
Correct |
28 ms |
984 KB |
Output is correct |
24 |
Correct |
29 ms |
984 KB |
Output is correct |
25 |
Correct |
27 ms |
984 KB |
Output is correct |
26 |
Correct |
31 ms |
1056 KB |
Output is correct |
27 |
Correct |
106 ms |
1180 KB |
Output is correct |
28 |
Correct |
95 ms |
1180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
1292 KB |
Output is correct |
2 |
Correct |
381 ms |
1292 KB |
Output is correct |
3 |
Execution timed out |
1082 ms |
1376 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |