제출 #1359497

#제출 시각아이디문제언어결과실행 시간메모리
1359497backer8002쌀 창고 (IOI11_ricehub)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

bool possible(int r, int amountOfHub , const int* x,long long b) {
    int bestHub = 0;
    int bestHubCount = 0;
    int count = 0;
    for (int i = 1; i < amountOfHub; i++)
        count += x[i] - x[0];
    bestHubCount = count;
    for (int i = 1; i < amountOfHub; i++) {
        int newCount = count+ (x[i] - x[i-1]) * (2*i-1-amountOfHub);
        if (newCount >= count) {
            bestHub = i-1;
            bestHubCount = count;
            break;
        }
        count = newCount;
    }

    if (bestHubCount <= b)
        return true;

    for (int i = 0; i < r-amountOfHub; i++) {
        int currentHub = bestHub;
        int currentCount = bestHubCount - x[bestHub] * 2 - x[i] + x[i+amountOfHub];
        for (int j = currentHub + 1; j < i + 1 +amountOfHub; j++) {
            int newCount = count + (x[j]-x[j-1]) * (2*(j-i+1) - 1 - amountOfHub);
            if (newCount >= count) {
                bestHub = j-1;
                bestHubCount = currentCount;
                break;
            }
            currentCount = newCount;
        }
        if (bestHubCount <= b)
            return true;
    }
    return false;
}

int besthub (int r, int, int* x,long long B) {
    int begin = 0,end = r;
    while (end - begin > 1) {
        int mid = (end+begin)/2;
        if (possible(r,mid,x,B))
            begin = mid;
        else
            end = mid;
    }
    if (possible(r,end,x,B))
        return end;
    return begin;
}
#if 1
int main() {
    int r,l,b;
    cin >> r >> l >> b;
    vector<int> vec(r);
    for (int& v : vec) cin >> v;
    cout << besthub(r,l,vec.data(),b);
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccbvIdQV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccpGzV9w.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status