#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
vector < long long > p(R , 0);
vector < long long > s(R , 0);
for( int i = 0; i < R; i++ ){
if( i )p[i] = p[i - 1];
p[i] += X[i];
}
for( int i = R - 1; i >= 0; i-- ){
if( i < R - 1 )s[i] = s[i + 1];
s[i] += X[i];
}
int ans = 0;
for( int i = 0; i < R; i++ ){
int l = 0 , r = i;
while( l < r ){
int m = (l + r) / 2;
int m1 = (m + i) / 2;
long long x = X[m1];
if( 1ll * x * (m1 - m + 1) - (p[m1] - (m > 0 ? p[m - 1] : 0)) +
1ll * x * (i - m1) - (s[i] - s[m1]) > B )l = m + 1;
else r = m;
}
ans = max( ans , i - l + 1 );
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |