#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;
int besthub(int R, int L, int X[], long long B)
{
int ans=0,mi,cnt=0,l,r;
long long int b = B;
for(int i=0;i<R;i++){
b=B;
l=i;r=i;
cnt=1;
//EXPAND
while(b>0){
mi=2e9;
//cout << r << ' ' << l << endl;
if(l>=1){
mi=min(abs(X[l-1]-X[i]),mi);
}
if(r<(L-1)){
mi=min(mi,abs(X[r+1]-X[i]));
}
if(mi==2e9)break;
if(b-mi < 0)break;
else{
cnt++;
b-=mi;
if(l>=1 && mi==abs(X[l-1]-X[i])){
l--;
}else{
r++;
}
}
}
ans=max(cnt,ans);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
33 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
484 KB |
Output is correct |
2 |
Correct |
12 ms |
468 KB |
Output is correct |
3 |
Execution timed out |
1050 ms |
1112 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |