#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], long long B)
{
int ans=0;
vector<ll> qs(R+1), v(R+1);
for (int i=0; i<R; i++) v[i+1]=X[i], qs[i+1]=qs[i]+v[i+1];
for (int i=1; i<=R; i++)
{
for (int j=i+1; j<=R; j++)
{
int md=(i+j)/2;
ll ls=v[md]*(md-i+1)-(qs[md]-qs[i-1]);
ll rs=qs[j]-qs[md]-v[md]*(j-md);
//cout<<i<<' '<<j<<' '<<ls<<' '<<rs<<'\n';
if (ls+rs<=B) ans=max(ans, j-i+1);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
312 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
1 ms |
312 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
316 KB |
Output is correct |
18 |
Correct |
1 ms |
316 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
316 KB |
Output is correct |
21 |
Correct |
28 ms |
412 KB |
Output is correct |
22 |
Correct |
28 ms |
428 KB |
Output is correct |
23 |
Correct |
32 ms |
340 KB |
Output is correct |
24 |
Correct |
32 ms |
340 KB |
Output is correct |
25 |
Correct |
32 ms |
340 KB |
Output is correct |
26 |
Correct |
32 ms |
428 KB |
Output is correct |
27 |
Correct |
31 ms |
444 KB |
Output is correct |
28 |
Correct |
31 ms |
428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
444 ms |
832 KB |
Output is correct |
2 |
Correct |
432 ms |
836 KB |
Output is correct |
3 |
Execution timed out |
1058 ms |
3244 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |