제출 #1145232

#제출 시각아이디문제언어결과실행 시간메모리
1145232thangdz2k7선물상자 (IOI15_boxes)C++20
컴파일 에러
0 ms0 KiB
#ifdef ONLINE_JUDGE

#include "boxes.h"

#endif // ONLINE_JUDGE

#include <bits/stdc++.h>

using namespace std;

const int MaxN = 1e7;
const long long inf = 1e18;

int pos[MaxN], n, k, len;
long long dp[MaxN];

int cost(int le, int ri){
    if (pos[ri] < len / 2) return pos[ri] * 2;
    if (pos[le] > len / 2) return (len - pos[le]) * 2;
    return len;
}

long long delivery(int N, int K, int L, int position[]){
    n = N, k = K, len = L;
    for (int i = 0; i < n; ++ i)
        pos[i] = position[i];

    for (int i = 0; i < n; ++ i){
        dp[i] = inf;
        for (int j = max(0, i - k + 1); j <= i; ++ j){
            long long tmp = 0;
            if (j) tmp = dp[j - 1];
            dp[i] = min(dp[i], tmp + cost(j, i));
        }
    }

    return dp[n - 1];
}

#ifndef ONLINE_JUDGE

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> k >> len;

    for (int i = 0; i < n; ++ i)
        cin >> pos[i];

    cout << delivery(n, k, len, pos);
}

/*
10 5 5
0 0 0 0 0 1 3 3 3 4
*/

#endif // ONLINE_JUDGE

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

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