답안 #485689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485689 2021-11-09T02:13:06 Z Joo 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

const int MXN = 1e5+10;
using ll = long long;

int a[MXN];

bool chk(int sz, int R, int B){
    int med = (sz+1)>>1;
    deque<ll> dq;
    ll rightsum = 0, leftsum = 0;
    for(int i = 1; i <= med; i++){
        leftsum += a[i];
        dq.push_back(a[i]);
    }
    for(int i = med+1; i <= R; i++){
        rightsum += a[i];
        dq.push_back(a[i]);
        if(i >= sz){
            ll tot = rightsum - (sz-med)*(dq[med-1]) + (med)*dq[med-1] - leftsum;
            if(tot <= B) return true;
            leftsum -= dq.front();
            leftsum += dq[med];
            rightsum -= dq[med];
            dq.pop_front();
        }
    }
    return false;
}

ll besthub(int R, int L, int X[], ll B){
    for(int i = 0; i < R; i++){
        a[i+1] = X[i];
    }

    int l = 2, r = R, ans = 1;
    while(l <= r){
        int mid = (l+r)>>1;

        if(chk(mid, R, B)){
            ans = mid;
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    return ans;
}
/*
int main(void){
    int R,L,B; cin >> R >> L >> B;
    int X[R] = {};
    for(int i = 0; i < R; i++){
        cin >> X[i];
    }
    cout << besthub(R, L, X, B) << "\n";
    return 0;
}
*/

Compilation message

ricehub.cpp:33:4: error: ambiguating new declaration of 'll besthub(int, int, int*, ll)'
   33 | ll besthub(int R, int L, int X[], ll B){
      |    ^~~~~~~
In file included from ricehub.cpp:2:
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);
      |     ^~~~~~~