답안 #384333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384333 2021-04-01T11:41:24 Z cpp219 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll inf = 1e9 + 7;
ll b[N];

ll Get(ll L,ll R){
    return b[R] - b[L - 1];
}

bool chk(ll m,ll n,ll B){
    for (ll i = 0;i < n - m + 1;i++){
        ll L = i,R = i + m - 1;
        ll mid = (L + R)/2; ll val = b[mid] - b[mid - 1];
        ll kq = val*(mid - L + 1) - Get(L,mid) + Get(mid,R) - val*(R - mid + 1);
        if (kq <= B) return 1;
    }
    //exit(0);
    return 0;
}

ll besthub(ll n,ll lim,ll a[],ll B){
    ll l,m,h; b[0] = a[0];
    for (ll i = 1;i < n;i++) b[i] = b[i - 1] + a[i]; //cout<<b[4]<<" "<<a[5]; exit(0);
    l = 0; h = n; //cout<<chk(4,n,B); exit(0);
    while(l <= h){
        m = (l + h)/2;
        if (chk(m,n,B)) l = m + 1;
        else h = m - 1;
    }
    return h;
}
/*
ll n,a[N],lim,B;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>n>>lim>>B;
    for (ll i = 1;i <= n;i++) cin>>a[i];
    cout<<besthub(n,lim,a,B);
}
*/

Compilation message

/tmp/ccnuv8IU.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