#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
long long ps[100069],inf=1e18;
int besthub(int n,int ln,int a[],long long d)
{
long long i,lh,rh,md,zz,mn;
for(i=1;i<=n;i++)
{
ps[i]=ps[i-1]+a[i-1];
}
for(lh=1,rh=n;lh<=rh;)
{
md=(lh+rh)/2;
mn=inf;
for(i=md;i<=n;i++)
{
mn=min(mn,ps[i]-ps[i-md/2]-ps[i-md+md/2]+ps[i-md]);
}
if(mn<=d)
{
zz=md;
lh=md+1;
}
else
{
rh=md-1;
}
}
return zz;
}
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:9: warning: 'zz' may be used uninitialized in this function [-Wmaybe-uninitialized]
34 | return zz;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2424 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2492 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2392 KB |
Output is correct |
19 |
Correct |
1 ms |
2392 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
26 |
Correct |
2 ms |
2396 KB |
Output is correct |
27 |
Correct |
2 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
2 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2500 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2652 KB |
Output is correct |
2 |
Correct |
3 ms |
2648 KB |
Output is correct |
3 |
Correct |
10 ms |
3672 KB |
Output is correct |
4 |
Correct |
9 ms |
3676 KB |
Output is correct |
5 |
Correct |
5 ms |
2904 KB |
Output is correct |
6 |
Correct |
5 ms |
3160 KB |
Output is correct |
7 |
Correct |
8 ms |
3264 KB |
Output is correct |
8 |
Correct |
9 ms |
3420 KB |
Output is correct |
9 |
Correct |
5 ms |
2784 KB |
Output is correct |
10 |
Correct |
5 ms |
2908 KB |
Output is correct |
11 |
Correct |
11 ms |
3548 KB |
Output is correct |
12 |
Correct |
11 ms |
3504 KB |
Output is correct |
13 |
Correct |
5 ms |
2908 KB |
Output is correct |
14 |
Correct |
5 ms |
2876 KB |
Output is correct |
15 |
Correct |
7 ms |
3372 KB |
Output is correct |
16 |
Correct |
9 ms |
3420 KB |
Output is correct |
17 |
Correct |
8 ms |
3420 KB |
Output is correct |
18 |
Correct |
9 ms |
3416 KB |
Output is correct |
19 |
Correct |
9 ms |
3676 KB |
Output is correct |
20 |
Correct |
9 ms |
3672 KB |
Output is correct |