#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
long long r=0, curr=0, cnt=0, res=0, 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;
}
}
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()){
res=max(res, cnt);
r++;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
420 KB |
Output is correct |
2 |
Correct |
2 ms |
524 KB |
Output is correct |
3 |
Correct |
3 ms |
664 KB |
Output is correct |
4 |
Correct |
4 ms |
664 KB |
Output is correct |
5 |
Correct |
3 ms |
664 KB |
Output is correct |
6 |
Correct |
4 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
696 KB |
Output is correct |
8 |
Correct |
4 ms |
832 KB |
Output is correct |
9 |
Correct |
3 ms |
832 KB |
Output is correct |
10 |
Correct |
2 ms |
832 KB |
Output is correct |
11 |
Correct |
5 ms |
832 KB |
Output is correct |
12 |
Correct |
3 ms |
832 KB |
Output is correct |
13 |
Correct |
2 ms |
832 KB |
Output is correct |
14 |
Correct |
4 ms |
832 KB |
Output is correct |
15 |
Correct |
3 ms |
832 KB |
Output is correct |
16 |
Incorrect |
3 ms |
832 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
952 KB |
Output is correct |
2 |
Correct |
6 ms |
1120 KB |
Output is correct |
3 |
Correct |
22 ms |
2536 KB |
Output is correct |
4 |
Correct |
23 ms |
3520 KB |
Output is correct |
5 |
Correct |
10 ms |
3760 KB |
Output is correct |
6 |
Correct |
9 ms |
4100 KB |
Output is correct |
7 |
Correct |
20 ms |
5064 KB |
Output is correct |
8 |
Correct |
18 ms |
5852 KB |
Output is correct |
9 |
Correct |
15 ms |
5860 KB |
Output is correct |
10 |
Correct |
15 ms |
6144 KB |
Output is correct |
11 |
Correct |
27 ms |
7456 KB |
Output is correct |
12 |
Correct |
41 ms |
8520 KB |
Output is correct |
13 |
Incorrect |
15 ms |
8728 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |