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=0;i<r-nr+1;i++)
{
st=i+1;
dr=i+nr;
mij=(st+dr)/2;
total=0;
total=total+x[mij-1]*(mij-st+1);
total=total-(sum[mij]-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 |
1 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 |
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 |
0 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
0 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 |
0 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 |
0 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 |
0 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 |
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 |
1 ms |
972 KB |
Output is correct |
6 |
Correct |
1 ms |
1036 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 |
1356 KB |
Output is correct |
4 |
Correct |
12 ms |
1424 KB |
Output is correct |
5 |
Correct |
7 ms |
1144 KB |
Output is correct |
6 |
Correct |
7 ms |
1228 KB |
Output is correct |
7 |
Correct |
11 ms |
1356 KB |
Output is correct |
8 |
Correct |
11 ms |
1460 KB |
Output is correct |
9 |
Correct |
6 ms |
1228 KB |
Output is correct |
10 |
Correct |
7 ms |
1228 KB |
Output is correct |
11 |
Correct |
12 ms |
1340 KB |
Output is correct |
12 |
Correct |
12 ms |
1356 KB |
Output is correct |
13 |
Incorrect |
9 ms |
1248 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |