#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
long long r=0, curr=0, cnt=0, res=1, i, mid, b;
int* x;
bool check(){
if((r-i)%2){
if(curr+x[r+1]-x[mid]<=b){
curr+=x[r+1]-x[mid];
cnt++;
return true;
}
return false;
}
else{
if(curr+(x[mid+1]-x[mid])+x[r+1]-x[mid+1]<=b){
curr+=(x[mid+1]-x[mid])+x[r+1]-x[mid+1];
cnt++;
mid++;
return true;
}
return false;
}
}
void del(){
if((r-i)%2){
curr-=x[mid]-x[i];
}
else{
curr-=x[mid]-x[i];
mid++;
}
cnt--;
}
int besthub(int R, int L, int X[], long long B){
x=X;
b=B;
for(i=0; i<R; i++){
r=max(r, i);
if(i==r){
mid=i;
curr=0;
cnt=1;
}
while(r+1<R && check()){
r++;
}
res=max(res, cnt);
del();
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
352 KB |
Output is correct |
3 |
Correct |
3 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
528 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
3 ms |
664 KB |
Output is correct |
6 |
Correct |
3 ms |
676 KB |
Output is correct |
7 |
Correct |
4 ms |
676 KB |
Output is correct |
8 |
Correct |
2 ms |
676 KB |
Output is correct |
9 |
Correct |
3 ms |
676 KB |
Output is correct |
10 |
Correct |
2 ms |
676 KB |
Output is correct |
11 |
Correct |
3 ms |
676 KB |
Output is correct |
12 |
Correct |
4 ms |
756 KB |
Output is correct |
13 |
Correct |
2 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
768 KB |
Output is correct |
16 |
Correct |
2 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
776 KB |
Output is correct |
18 |
Correct |
2 ms |
776 KB |
Output is correct |
19 |
Correct |
2 ms |
776 KB |
Output is correct |
20 |
Correct |
4 ms |
776 KB |
Output is correct |
21 |
Correct |
1 ms |
792 KB |
Output is correct |
22 |
Correct |
4 ms |
796 KB |
Output is correct |
23 |
Correct |
2 ms |
796 KB |
Output is correct |
24 |
Correct |
3 ms |
796 KB |
Output is correct |
25 |
Correct |
4 ms |
808 KB |
Output is correct |
26 |
Correct |
4 ms |
812 KB |
Output is correct |
27 |
Correct |
3 ms |
816 KB |
Output is correct |
28 |
Correct |
3 ms |
820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
820 KB |
Output is correct |
2 |
Correct |
3 ms |
820 KB |
Output is correct |
3 |
Correct |
3 ms |
820 KB |
Output is correct |
4 |
Correct |
3 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
2 ms |
824 KB |
Output is correct |
7 |
Correct |
4 ms |
824 KB |
Output is correct |
8 |
Correct |
3 ms |
824 KB |
Output is correct |
9 |
Correct |
2 ms |
824 KB |
Output is correct |
10 |
Correct |
2 ms |
824 KB |
Output is correct |
11 |
Correct |
2 ms |
824 KB |
Output is correct |
12 |
Correct |
3 ms |
824 KB |
Output is correct |
13 |
Correct |
3 ms |
824 KB |
Output is correct |
14 |
Correct |
3 ms |
824 KB |
Output is correct |
15 |
Correct |
3 ms |
824 KB |
Output is correct |
16 |
Correct |
3 ms |
824 KB |
Output is correct |
17 |
Correct |
4 ms |
828 KB |
Output is correct |
18 |
Correct |
3 ms |
960 KB |
Output is correct |
19 |
Correct |
3 ms |
960 KB |
Output is correct |
20 |
Correct |
3 ms |
960 KB |
Output is correct |
21 |
Correct |
5 ms |
960 KB |
Output is correct |
22 |
Correct |
5 ms |
1024 KB |
Output is correct |
23 |
Correct |
4 ms |
1024 KB |
Output is correct |
24 |
Correct |
5 ms |
1024 KB |
Output is correct |
25 |
Correct |
4 ms |
1024 KB |
Output is correct |
26 |
Correct |
5 ms |
1160 KB |
Output is correct |
27 |
Correct |
4 ms |
1160 KB |
Output is correct |
28 |
Correct |
6 ms |
1212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1212 KB |
Output is correct |
2 |
Correct |
7 ms |
1212 KB |
Output is correct |
3 |
Correct |
20 ms |
1568 KB |
Output is correct |
4 |
Correct |
23 ms |
1568 KB |
Output is correct |
5 |
Correct |
10 ms |
1568 KB |
Output is correct |
6 |
Correct |
14 ms |
1568 KB |
Output is correct |
7 |
Correct |
36 ms |
1568 KB |
Output is correct |
8 |
Correct |
32 ms |
1568 KB |
Output is correct |
9 |
Correct |
9 ms |
1568 KB |
Output is correct |
10 |
Correct |
11 ms |
1568 KB |
Output is correct |
11 |
Correct |
26 ms |
1568 KB |
Output is correct |
12 |
Correct |
23 ms |
1568 KB |
Output is correct |
13 |
Correct |
13 ms |
1568 KB |
Output is correct |
14 |
Correct |
13 ms |
1696 KB |
Output is correct |
15 |
Correct |
24 ms |
2596 KB |
Output is correct |
16 |
Correct |
28 ms |
3400 KB |
Output is correct |
17 |
Correct |
26 ms |
4456 KB |
Output is correct |
18 |
Correct |
27 ms |
5408 KB |
Output is correct |
19 |
Correct |
25 ms |
6348 KB |
Output is correct |
20 |
Correct |
35 ms |
7352 KB |
Output is correct |