bool verify(long long sum[], int r, int l, int x[], long long b, int nr)
{
int st, dr, mij;
long long total;
for(int i=1;i<=r-nr+1;i++)
{
st=i;
dr=i+nr-1;
mij=(st+dr)/2;
total=0;
total=total+x[mij-1]*(mij-st);
total=total-(sum[mij-1]-sum[st-1]);
total=total+(sum[dr]-sum[mij]);
total=total-x[mij-1]*(dr-mij);
if(total<=b)
return true;
}
return false;
}
int besthub(int r, int l, int x[], long long b)
{
long long sum[100005]={};
sum[0]=0;
for(int i=1;i<=r;i++)
sum[i]=sum[i-1]+x[i-1];
int st=1, dr=r+1, mij;
while(dr-st>1)
{
mij=(st+dr)/2;
if(verify(sum,r,l,x,b,mij))
st=mij;
else
dr=mij;
}
return st;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
0 ms |
972 KB |
Output is correct |
4 |
Correct |
0 ms |
972 KB |
Output is correct |
5 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
1 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
972 KB |
Output is correct |
5 |
Correct |
0 ms |
972 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
0 ms |
972 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
1 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
972 KB |
Output is correct |
21 |
Correct |
1 ms |
972 KB |
Output is correct |
22 |
Correct |
1 ms |
972 KB |
Output is correct |
23 |
Correct |
1 ms |
972 KB |
Output is correct |
24 |
Correct |
1 ms |
972 KB |
Output is correct |
25 |
Correct |
1 ms |
972 KB |
Output is correct |
26 |
Correct |
1 ms |
972 KB |
Output is correct |
27 |
Correct |
1 ms |
972 KB |
Output is correct |
28 |
Correct |
0 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
972 KB |
Output is correct |
2 |
Correct |
1 ms |
1024 KB |
Output is correct |
3 |
Correct |
1 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
972 KB |
Output is correct |
5 |
Correct |
1 ms |
972 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
972 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
1 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
972 KB |
Output is correct |
21 |
Correct |
1 ms |
972 KB |
Output is correct |
22 |
Correct |
1 ms |
972 KB |
Output is correct |
23 |
Correct |
1 ms |
972 KB |
Output is correct |
24 |
Correct |
1 ms |
972 KB |
Output is correct |
25 |
Correct |
1 ms |
972 KB |
Output is correct |
26 |
Correct |
1 ms |
972 KB |
Output is correct |
27 |
Correct |
1 ms |
972 KB |
Output is correct |
28 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1100 KB |
Output is correct |
2 |
Correct |
3 ms |
1100 KB |
Output is correct |
3 |
Correct |
13 ms |
1464 KB |
Output is correct |
4 |
Correct |
13 ms |
1424 KB |
Output is correct |
5 |
Correct |
7 ms |
1228 KB |
Output is correct |
6 |
Correct |
8 ms |
1228 KB |
Output is correct |
7 |
Correct |
15 ms |
1356 KB |
Output is correct |
8 |
Correct |
12 ms |
1356 KB |
Output is correct |
9 |
Correct |
6 ms |
1228 KB |
Output is correct |
10 |
Correct |
7 ms |
1232 KB |
Output is correct |
11 |
Correct |
13 ms |
1356 KB |
Output is correct |
12 |
Correct |
15 ms |
1364 KB |
Output is correct |
13 |
Correct |
7 ms |
1180 KB |
Output is correct |
14 |
Correct |
8 ms |
1612 KB |
Output is correct |
15 |
Correct |
10 ms |
2112 KB |
Output is correct |
16 |
Correct |
11 ms |
2116 KB |
Output is correct |
17 |
Correct |
13 ms |
2252 KB |
Output is correct |
18 |
Correct |
15 ms |
2252 KB |
Output is correct |
19 |
Correct |
12 ms |
2380 KB |
Output is correct |
20 |
Correct |
12 ms |
2360 KB |
Output is correct |