#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
long long pre[100005]={0};
int besthub(int R,int L,int *X,long long B){
int i,j=-1,ans=0;
pre[0]=X[0];
for(i=1;i<R;i++)
pre[i]=pre[i-1]+X[i];
for(i=0;i<R;i++){
while(j+1<R&&pre[j+1]-pre[(j+1+i)/2]-(long long)X[(j+1+i)/2]*(j+1-(j+1+i)/2)+(long long)X[(j+1+i)/2]*((j+1+i)/2-i+1)-pre[(j+1+i)/2]+(i?pre[i-1]:0)<=B)
j++;
// j--;
//1 1->1 2
// printf("%d %d %lld\n",i,j,pre[j+1]-pre[(j+1+i)/2]-(long long)X[(j+1+i)/2]*(j+1-(j+1+i)/2)+(long long)X[(j+1+i)/2]*((j+1+i)/2-i+1)-pre[(j+1+i)/2]+(i?pre[i-1]:0));
// printf("%lld %lld\n",pre[j+1]-pre[(j+1+i)/2]-(long long)X[(j+1+i)/2]*(j+1-(j+1+i)/2),(long long)X[(j+1+i)/2]*((j+1+i)/2-i+1)-pre[(j+1+i)/2]+(i?pre[i-1]:0));
// j++;
// printf("%d\n",j-i+1);
ans=max(ans,j-i+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
128 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
4 ms |
256 KB |
Output is correct |
15 |
Correct |
4 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
4 ms |
256 KB |
Output is correct |
23 |
Correct |
5 ms |
256 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
5 ms |
256 KB |
Output is correct |
26 |
Correct |
4 ms |
384 KB |
Output is correct |
27 |
Correct |
4 ms |
256 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
128 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Output is correct |
2 |
Correct |
7 ms |
640 KB |
Output is correct |
3 |
Correct |
21 ms |
2560 KB |
Output is correct |
4 |
Correct |
21 ms |
2560 KB |
Output is correct |
5 |
Correct |
11 ms |
1280 KB |
Output is correct |
6 |
Correct |
11 ms |
1280 KB |
Output is correct |
7 |
Correct |
18 ms |
2304 KB |
Output is correct |
8 |
Correct |
17 ms |
2304 KB |
Output is correct |
9 |
Correct |
10 ms |
1152 KB |
Output is correct |
10 |
Correct |
11 ms |
1152 KB |
Output is correct |
11 |
Correct |
24 ms |
2552 KB |
Output is correct |
12 |
Correct |
22 ms |
2560 KB |
Output is correct |
13 |
Correct |
11 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
19 ms |
1920 KB |
Output is correct |
16 |
Correct |
20 ms |
2048 KB |
Output is correct |
17 |
Correct |
24 ms |
2304 KB |
Output is correct |
18 |
Correct |
20 ms |
2304 KB |
Output is correct |
19 |
Correct |
23 ms |
2432 KB |
Output is correct |
20 |
Correct |
21 ms |
2432 KB |
Output is correct |