#include "ricehub.h"
#include<algorithm>
using namespace std;
int besthub(int r, int l, int x[], long long b){
int duz=0;
long long cena=0;
int res=0;
for(int i=0;i<r;i++){
while(i-duz-1>=0 && i+duz+1<r){
if(cena+abs(x[i]-x[i-duz-1])+abs(x[i]-x[i+duz+1])>b) break;
cena+=abs(x[i]-x[i-duz-1])+abs(x[i]-x[i+duz+1]);
duz++;
}
res=max(res,2*duz+1);
if(i-duz-1>=0){
if(cena+abs(x[i]-x[i-duz-1])<=b) res=max(res,2*duz+2);
}
if(i+duz+1<r){
if(cena+abs(x[i]-x[i+duz+1])<=b) res=max(res,2*duz+2);
}
duz--;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
292 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |