# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
880437 |
2023-11-29T12:30:38 Z |
andro |
Rice Hub (IOI11_ricehub) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "ricehub.h"
#define int long long
using namespace std;
int besthub(int R, int L, int X[], long long B){
int ans=0;
for(int i=1;i<=R;i++){
//od desno kolko ih ima u [X[i],X[i]+mid]
// od levo [X[i]-mid,X[i]]
int l=0,r=1e15+1,p=-1;
while(l<=r){
int mid=(l+r)/2;
int c=0;
for(int j=1;j<=R;j++){
if(abs(X[i]-X[j])<=mid)c+=abs(X[i]-X[j]);
}
if(c<=B){
l=mid+1;
p=mid;
}
else {
r=mid-1;
}
}
int u=0;
for(int j=1;j<=R;j++){
if(abs(X[i]-X[j])<=p)u++;
}
ans=max(ans,u);
}
return ans;
}/*
signed main(){
int X[4]={0,10,12,14};
cout<<besthub(3,14,X,6);
}*/
/*
1 3
2 3
3 3
3
*/
Compilation message
/usr/bin/ld: /tmp/ccNlb38y.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status