#include "ricehub.h"
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include"bits/stdc++.h"
#endif
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
long long int arr[R+1],p[R+1]={0};
for(int i=1;i<=R;i++){
arr[i]=X[i-1];
p[i]=p[i-1]+arr[i];
}
int ptr1=1,ptr2=1,ans=1;
while(ptr2<=R){
if(ptr1==ptr2){
ptr2++;
}
int m1=(ptr1+ptr2)/2,m2=m1+(ptr1+ptr2)%2;
long long int td=(p[ptr2]-p[m2-1])-(p[m1]-p[ptr1-1]);
if(td<=B){
ans=max(ans,ptr2-ptr1+1);
ptr2++;
}
else{
ptr1++;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
448 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
440 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
456 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
1 ms |
488 KB |
Output is correct |
26 |
Correct |
1 ms |
600 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
11 ms |
5212 KB |
Output is correct |
4 |
Correct |
10 ms |
5212 KB |
Output is correct |
5 |
Correct |
6 ms |
3676 KB |
Output is correct |
6 |
Correct |
7 ms |
3676 KB |
Output is correct |
7 |
Correct |
9 ms |
4900 KB |
Output is correct |
8 |
Correct |
10 ms |
4956 KB |
Output is correct |
9 |
Correct |
5 ms |
3676 KB |
Output is correct |
10 |
Correct |
5 ms |
3676 KB |
Output is correct |
11 |
Correct |
10 ms |
5212 KB |
Output is correct |
12 |
Correct |
10 ms |
5212 KB |
Output is correct |
13 |
Correct |
5 ms |
3688 KB |
Output is correct |
14 |
Correct |
5 ms |
3692 KB |
Output is correct |
15 |
Correct |
8 ms |
4444 KB |
Output is correct |
16 |
Correct |
8 ms |
4444 KB |
Output is correct |
17 |
Correct |
9 ms |
4948 KB |
Output is correct |
18 |
Correct |
9 ms |
4956 KB |
Output is correct |
19 |
Correct |
10 ms |
4952 KB |
Output is correct |
20 |
Correct |
10 ms |
4956 KB |
Output is correct |