#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
int ans = 0;
int l = 0;
int r = 0;
for (int i = 0; i < R; i++) {
if (i > 0) {
B -= 1ll * (X[i] - X[i - 1]) * (i - l);
B += 1ll * (X[i] - X[i - 1]) * (r - i);
}
while (B < 0) {
B += X[i] - X[l];
l++;
}
while (r < R && B >= X[r] - X[i]) {
B -= X[r] - X[i];
r++;
}
while (r < R && B + X[i] - X[l] >= X[r] - X[i]) {
B += X[i] - X[l] - X[r] - X[i];
r++;
}
ans = max(ans, r - l);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |