#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;
bool solve(ll m, ll r, int x[], ll b) {
ll xd = 0;
for(int i=0; i<m; i++) {
xd+=abs(x[m/2]-x[i]);
}
if(xd <= b) {
return true;
}
for(ll i = 1; i < r-m; i++) {
xd-=(x[m/2+i-1]-x[i-1]);
xd+=(x[m+i]-x[m/2+i]);
xd-=(x[m/2+i]-x[m/2+i-1])*(m%2);
if(xd <= b) return true;
}
return false;
}
ll besthub(int r, int l, int x[], long long b) {
ll u = 0;
ll m;
ll v = r;
while(u < v) {
m = ceil((u+v)/2.0);
if(solve(m, r, x, b)) {
u = m;
}
else {
v = m-1;
}
}
return u;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
344 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 |
344 KB |
Output is correct |
20 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
348 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
2672 KB |
Output is correct |
4 |
Correct |
10 ms |
2648 KB |
Output is correct |
5 |
Correct |
5 ms |
2652 KB |
Output is correct |
6 |
Correct |
5 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
9 ms |
2652 KB |
Output is correct |
9 |
Correct |
4 ms |
2652 KB |
Output is correct |
10 |
Incorrect |
4 ms |
2668 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |