답안 #718764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718764 2023-04-04T17:41:27 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define oo 1e9
#define pii pair<int, int>

const int MAX = 1e5 + 5;

int n, L;
ll B;
int arr[MAX];
ll PreSum[MAX];

bool check(int k){
    for(int i = 0; i < n - k + 1; i++){
        int l = i;
        int r = i + k - 1;
        int mid = (l + r) / 2;
        ll money = 1ll * (mid - l + 1) * arr[mid] - (r - mid + 1) * arr[mid];
        money += -(PreSum[mid] - PreSum[l - 1]) + (PreSum[r] - PreSum[mid - 1]);
        if(money <= B){
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n >> L;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    cin >> B;
    for(int i = 1; i <= n; i++){
        PreSum[i] = PreSum[i - 1] + arr[i - 1];
    }

    int ans = 0;
    int l = 0, r = 1e5;
    while(l <= r){
        int m = (l + r) / 2;
        if(check(m)){
            l = m + 1;
            ans = max(ans, m);
        }
        else{
            r = m - 1;
        }
    }
    cout << ans;
}

Compilation message

/usr/bin/ld: /tmp/ccqeQ1Br.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdkSutt.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqeQ1Br.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