#include "ricehub.h"
#include<algorithm>
#define MX 100004
using namespace std;
int x[MX],n;
long long int r=1,BB;
int OK(int X){
int i;
for(i=1;i<=n-X+1;i++){
r=x[i+X-1]-x[i];
r*=((long long int)X/2);
if(r<=BB){return 1;}
}
return 0;
}
int besthub(int R, int L, int X[], long long B){
n=R;
int s=0,e=n+1,m;
BB=B;
int i;
for(i=1;i<=n;i++){x[i]=X[i-1];}
sort(x+1,x+1+n);
for(;;){
if((s+1)==e)return s;
m=(s+e)/2;
if(OK(m)==1){s=m;}
else{e=m;}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5380 KB |
Output is correct |
2 |
Incorrect |
0 ms |
5380 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5380 KB |
Output is correct |
2 |
Correct |
0 ms |
5380 KB |
Output is correct |
3 |
Correct |
0 ms |
5380 KB |
Output is correct |
4 |
Incorrect |
0 ms |
5380 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |