Submission #304587

#TimeUsernameProblemLanguageResultExecution timeMemory
304587hieppggaRice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define int long long using namespace std; int n,l,k,a[100004],sum[100004],ans; bool solve(int flag,int res) { int rig=flag+res; if(sum[flag+res]-sum[flag]-a[flag]*res+res*a[flag]-(sum[flag-1]-sum[flag-res-1])<=k) return true; return false; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>l>>k; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+n+1); for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i]; for(int i=1;i<=n;i++) { int l=0,r=min(i-1,n-i),mid; while(l<=r) { mid=(l+r)/2; if(solve(i,mid)) l=mid+1; else r=mid-1; } ans=max(ans,2*r+1); } cout<<ans; }

Compilation message (stderr)

ricehub.cpp: In function 'bool solve(long long int, long long int)':
ricehub.cpp:11:9: warning: unused variable 'rig' [-Wunused-variable]
   11 |     int rig=flag+res;
      |         ^~~
/tmp/ccnmvAfO.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccWwuONw.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/ccnmvAfO.o: In function `main':
grader.cpp:(.text.startup+0x9a): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status