#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
int besthub(int n, int, int* x, long long b) {
vector<long long> pref(n + 1);
for (int i = 0; i < n; i++) {
pref[i + 1] = pref[i] + x[i];
}
int lo = 1;
int hi = n + 1;
while (hi - lo > 1) {
int mid = (hi + lo) / 2;
int ok = 0;
for (int i = 0; i + mid <= n; i++) {
for (int j = max(i, (i + i + mid) / 2 - 1); j <= min(i + mid, (i + i + mid) / 2 + 1); j++) {
long long c = pref[i + mid] - pref[j] - 1LL * x[j] * (i + mid - j);
c += 1LL * x[j] * (j - i) - (pref[j] - pref[i]);
if (c <= b) {
ok = 1;
}
}
}
if (ok) {
lo = mid;
} else {
hi = mid;
}
}
return lo;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
304 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
304 KB |
Output is correct |
16 |
Correct |
1 ms |
296 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
312 KB |
Output is correct |
22 |
Correct |
2 ms |
292 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
312 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
568 KB |
Output is correct |
2 |
Correct |
5 ms |
588 KB |
Output is correct |
3 |
Correct |
12 ms |
2484 KB |
Output is correct |
4 |
Correct |
12 ms |
2460 KB |
Output is correct |
5 |
Correct |
16 ms |
1136 KB |
Output is correct |
6 |
Correct |
13 ms |
1212 KB |
Output is correct |
7 |
Correct |
10 ms |
2112 KB |
Output is correct |
8 |
Correct |
11 ms |
2188 KB |
Output is correct |
9 |
Correct |
12 ms |
1100 KB |
Output is correct |
10 |
Correct |
11 ms |
1080 KB |
Output is correct |
11 |
Correct |
12 ms |
2500 KB |
Output is correct |
12 |
Correct |
18 ms |
2496 KB |
Output is correct |
13 |
Correct |
13 ms |
1156 KB |
Output is correct |
14 |
Correct |
13 ms |
1208 KB |
Output is correct |
15 |
Correct |
9 ms |
1956 KB |
Output is correct |
16 |
Correct |
10 ms |
1868 KB |
Output is correct |
17 |
Correct |
11 ms |
2232 KB |
Output is correct |
18 |
Correct |
11 ms |
2228 KB |
Output is correct |
19 |
Correct |
13 ms |
2352 KB |
Output is correct |
20 |
Correct |
12 ms |
2372 KB |
Output is correct |