답안 #552020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552020 2022-04-22T08:17:09 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(int R, int L, int 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: At global scope:
ricehub.cpp:34:15: error: ambiguating new declaration of 'long long int besthub(int, int, int*, long long int)'
   34 |     long long besthub(int R, int L, int X[], long long B)
      |               ^~~~~~~
In file included from ricehub.cpp:1:
ricehub.h:1:5: note: old declaration 'int besthub(int, int, int*, long long int)'
    1 | int besthub(int R, int L, int X[], long long B);
      |     ^~~~~~~
ricehub.cpp: In function 'long long int besthub(int, int, int*, long long int)':
ricehub.cpp:44:19: warning: unused variable 'mx' [-Wunused-variable]
   44 |         long long mx=1;
      |                   ^~