#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
ll prefs[100010];
ll cost(int l, int r, int *x)
{
int m=(l+r)/2;
return prefs[r]-prefs[m]-(r-m)*x[m]+prefs[m]-prefs[l]-(m-l)*x[l];
}
int besthub(int R, int L, int *X, ll B)
{
prefs[0]=X[0];
for(int i=1; i<R; i++)prefs[i]=prefs[i-1]+X[i];
int k=0, ans=0;
for(int i=0; i<R; i++)
{
while(cost(k, i, X)>B)k++;
ans=max(i-k+1, ans);
}
return ans;
}
/*int main()
{
int r, l, x[100010];
ll b;
cin>>r>>l;
for(int i=0; i<r; i++)cin>>x[i];
cin>>b;
cout<<besthub(r, l, x, b);
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
312 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
3 |
Correct |
12 ms |
2512 KB |
Output is correct |
4 |
Incorrect |
12 ms |
2476 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |