#include<bits/stdc++.h>
using namespace std;
long long k,prefsum[100005],mid,midin,L,R,pas,curprice,a[100005];
long long besthub(int r,int l,int x[],long long b ){
for(k=1;k<=r;k++){
a[k]=x[k-1];
prefsum[k]=prefsum[k-1]+a[k];
}
for(k=1;k<=r;k++){
L=k; R=r;
while(L<=R){
mid=(L+R+1)/2;
midin=(mid+k)/2;
curprice=prefsum[mid]-prefsum[midin]-(mid-midin)*a[midin]
+ (midin-k+1)*a[midin]-prefsum[midin]+prefsum[k-1];
// cout<<k<<" "<<mid<<" = "<<curprice<<endl;
if(curprice<=b){
L=mid+1; pas=max(pas,mid-k+1);
}
else R=mid-1;
}
}
return pas;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
252 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
400 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
408 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
408 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
380 KB |
Output is correct |
21 |
Correct |
3 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
504 KB |
Output is correct |
26 |
Correct |
3 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
416 KB |
Output is correct |
28 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
888 KB |
Output is correct |
2 |
Correct |
6 ms |
888 KB |
Output is correct |
3 |
Correct |
25 ms |
3320 KB |
Output is correct |
4 |
Correct |
26 ms |
3320 KB |
Output is correct |
5 |
Correct |
12 ms |
1656 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
23 ms |
3064 KB |
Output is correct |
8 |
Correct |
25 ms |
3064 KB |
Output is correct |
9 |
Correct |
13 ms |
1536 KB |
Output is correct |
10 |
Correct |
13 ms |
1528 KB |
Output is correct |
11 |
Correct |
28 ms |
3352 KB |
Output is correct |
12 |
Correct |
29 ms |
3320 KB |
Output is correct |
13 |
Correct |
13 ms |
1656 KB |
Output is correct |
14 |
Correct |
13 ms |
1660 KB |
Output is correct |
15 |
Correct |
20 ms |
2552 KB |
Output is correct |
16 |
Correct |
21 ms |
2552 KB |
Output is correct |
17 |
Correct |
24 ms |
2936 KB |
Output is correct |
18 |
Correct |
24 ms |
3056 KB |
Output is correct |
19 |
Correct |
25 ms |
3192 KB |
Output is correct |
20 |
Correct |
27 ms |
3192 KB |
Output is correct |