Submission #880438

#TimeUsernameProblemLanguageResultExecution timeMemory
880438androRice Hub (IOI11_ricehub)C++14
17 / 100
1038 ms600 KiB
#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 (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:10:23: warning: overflow in conversion from 'double' to 'int' changes value from '1.000000000000001e+15' to '2147483647' [-Woverflow]
   10 |         int l=0,r=1e15+1,p=-1;
      |                   ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...