#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
long long S(int X[], int h, int l, int r)
{
long long sum = 0;
for(int i = l; i<=r; i++)
sum = sum + abs(h-X[i]);
return sum;
}
int besthub(int R, int L, int X[], long long B)
{
int res = 0;
int r = R;
int counter = 0;
while(true)
{
int k = r/2;
bool flag = false;
for(int i = 0; i<=R-k; i++)
{
int curr = S(X, X[(2*i+k-1)/2], i, i+k-1);
if(curr<=B)
flag = true;
}
if(flag)
{
r++;
counter++;
}
else
{
if(counter>0)
{
res = (k-1);
break;
}
r = k;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
20 ms |
204 KB |
Output is correct |
24 |
Correct |
21 ms |
296 KB |
Output is correct |
25 |
Correct |
19 ms |
296 KB |
Output is correct |
26 |
Correct |
19 ms |
296 KB |
Output is correct |
27 |
Correct |
15 ms |
204 KB |
Output is correct |
28 |
Correct |
15 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
190 ms |
204 KB |
Output is correct |
4 |
Correct |
126 ms |
280 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
6 ms |
204 KB |
Output is correct |
8 |
Correct |
6 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
296 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
204 KB |
Output is correct |
13 |
Correct |
164 ms |
284 KB |
Output is correct |
14 |
Correct |
173 ms |
288 KB |
Output is correct |
15 |
Correct |
10 ms |
204 KB |
Output is correct |
16 |
Correct |
11 ms |
204 KB |
Output is correct |
17 |
Correct |
84 ms |
204 KB |
Output is correct |
18 |
Correct |
84 ms |
204 KB |
Output is correct |
19 |
Correct |
169 ms |
284 KB |
Output is correct |
20 |
Correct |
165 ms |
280 KB |
Output is correct |
21 |
Correct |
160 ms |
296 KB |
Output is correct |
22 |
Correct |
158 ms |
332 KB |
Output is correct |
23 |
Execution timed out |
1089 ms |
332 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
303 ms |
356 KB |
Output is correct |
2 |
Correct |
279 ms |
360 KB |
Output is correct |
3 |
Execution timed out |
1087 ms |
588 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |