답안 #552018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552018 2022-04-22T08:16:13 Z ala2 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
   #include "ricehub.h"
    #include <iostream>
    using namespace std;
    long long n,d;
    long long a[1000100];
    long long b;
    long long P[1001000];
    long long f(long long i,long long j)
    {
        long long x=(i+j)/2;
        long long ta=j-i+1;
        long long one=P[x]-P[i]+a[i]-a[x];
        long long g=0;
        long long ta1=x-i;
        g=ta1*a[x]-one;
        long long tow=P[j]-P[x];
        long long ta2=j-x;
        g+=tow-ta2*a[x];
        return g;
    }
    long long ok(long long mid)
    {
        for(long long i=0;i<n;i++)
        {
            if(i+mid>=n)
                break;
            if(f(i,i+mid)<=b)
            {
                return 1;
            }
        }
        return 0;
    }
    long long besthub(long long R, long long L, long long X[], long long B)
    {
        n=R;
        d=L;
        b=B;
        for(long long i=0;i<n;i++)
            a[i]=X[i];
        P[0]=a[0];
        for(long long i=1;i<n;i++)
          P[i]=P[i-1]+a[i];
        long long mx=1;
        long long l=0;
        long long r=n;
        while(r-l>1)
        {
            long long mid=(l+r)/2;
            if(ok(mid))
            {
                l=mid;
            }
            else r=mid;
        }

        long long ann=l+1;
        //cout<<mx<<endl;
        return ann;
    }

Compilation message

ricehub.cpp: In function 'long long int f(long long int, long long int)':
ricehub.cpp:11:19: warning: unused variable 'ta' [-Wunused-variable]
   11 |         long long ta=j-i+1;
      |                   ^~
ricehub.cpp: In function 'long long int besthub(long long int, long long int, long long int*, long long int)':
ricehub.cpp:44:19: warning: unused variable 'mx' [-Wunused-variable]
   44 |         long long mx=1;
      |                   ^~
/usr/bin/ld: /tmp/ccMcbLmc.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