답안 #304589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304589 2020-09-21T14:41:20 Z hieppgga 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#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)
{
    if(sum[flag+res]-sum[flag]-a[flag]*res+res*a[flag]-(sum[flag-1]-sum[flag-res-1])<=k) return true;
    return false;
}
 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

ricehub.cpp:14:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 |  main()
      |       ^
/tmp/cc0Mm2c6.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cckRaLpH.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/cc0Mm2c6.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