#include<bits/stdc++.h>
using namespace std;
long long qs[100005],l,r,mid,new_mid,new_val,ans;
int besthub(int n, int m, int x[100005], long long b){
int i;
for(i=n;i>0;i--)x[i]=x[i-1];
x[0]=0;
for(i=1;i<=n;i++)qs[i]=qs[i-1]+x[i];
l=1,r=1,mid=1;
for(l=1;l<=n;l++){
while(1){
if(r==n)break;
new_mid=(l+r+1)/2;
new_val=x[new_mid]*(new_mid-l)-qs[new_mid-1]+qs[l-1]+qs[r+1]-qs[new_mid]-x[new_mid]*(r+1-new_mid);
if(new_val<=b)mid=new_mid,r++;
else break;
}
ans=max(ans,r-l+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 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 |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
304 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 |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
296 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
332 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 |
296 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 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 |
332 KB |
Output is correct |
15 |
Correct |
0 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 |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
292 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
312 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
308 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
612 KB |
Output is correct |
2 |
Correct |
3 ms |
588 KB |
Output is correct |
3 |
Correct |
13 ms |
2424 KB |
Output is correct |
4 |
Correct |
12 ms |
2420 KB |
Output is correct |
5 |
Correct |
5 ms |
1160 KB |
Output is correct |
6 |
Correct |
5 ms |
1204 KB |
Output is correct |
7 |
Correct |
10 ms |
2204 KB |
Output is correct |
8 |
Correct |
12 ms |
2124 KB |
Output is correct |
9 |
Correct |
5 ms |
1092 KB |
Output is correct |
10 |
Correct |
5 ms |
1076 KB |
Output is correct |
11 |
Correct |
18 ms |
2500 KB |
Output is correct |
12 |
Correct |
13 ms |
2440 KB |
Output is correct |
13 |
Correct |
6 ms |
1232 KB |
Output is correct |
14 |
Correct |
5 ms |
1208 KB |
Output is correct |
15 |
Correct |
9 ms |
1884 KB |
Output is correct |
16 |
Correct |
10 ms |
1868 KB |
Output is correct |
17 |
Correct |
11 ms |
2252 KB |
Output is correct |
18 |
Correct |
12 ms |
2280 KB |
Output is correct |
19 |
Correct |
13 ms |
2512 KB |
Output is correct |
20 |
Correct |
13 ms |
2388 KB |
Output is correct |