#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int ans = 0;
long long sumL[R+2]={}, sumR[R+2]={};
for( int i = 1; i <= R; i ++ ){
sumL[i] = sumL[i-1] + X[i-1];
}
for( int i = R; i >= 1; i -- ){
sumR[i] = sumR[i+1] + X[i-1];
}
for( int i = 1; i <= R; i ++ ){
for( int j = 1; j <= i; j ++ ){
for( int k = i; k <= R; k ++ ){
if(X[i-1]*(i-j+1)-(sumL[i]-sumL[j-1]) + (sumR[i]-sumR[k+1])-X[i-1]*(k-i+1)<=B){
ans = max( ans, k-j+1);
}
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
40 ms |
376 KB |
Output is correct |
22 |
Correct |
39 ms |
376 KB |
Output is correct |
23 |
Correct |
45 ms |
376 KB |
Output is correct |
24 |
Correct |
45 ms |
384 KB |
Output is correct |
25 |
Correct |
45 ms |
376 KB |
Output is correct |
26 |
Correct |
45 ms |
376 KB |
Output is correct |
27 |
Correct |
40 ms |
376 KB |
Output is correct |
28 |
Correct |
41 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
251 ms |
384 KB |
Output is correct |
4 |
Correct |
245 ms |
376 KB |
Output is correct |
5 |
Correct |
38 ms |
384 KB |
Output is correct |
6 |
Correct |
39 ms |
376 KB |
Output is correct |
7 |
Correct |
265 ms |
504 KB |
Output is correct |
8 |
Correct |
270 ms |
504 KB |
Output is correct |
9 |
Correct |
39 ms |
384 KB |
Output is correct |
10 |
Correct |
38 ms |
376 KB |
Output is correct |
11 |
Correct |
143 ms |
384 KB |
Output is correct |
12 |
Correct |
140 ms |
504 KB |
Output is correct |
13 |
Correct |
336 ms |
384 KB |
Output is correct |
14 |
Correct |
329 ms |
384 KB |
Output is correct |
15 |
Correct |
41 ms |
376 KB |
Output is correct |
16 |
Correct |
41 ms |
376 KB |
Output is correct |
17 |
Correct |
171 ms |
384 KB |
Output is correct |
18 |
Correct |
170 ms |
384 KB |
Output is correct |
19 |
Correct |
331 ms |
392 KB |
Output is correct |
20 |
Correct |
326 ms |
504 KB |
Output is correct |
21 |
Execution timed out |
1087 ms |
384 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |