제출 #1309383

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

struct Artifact {
    int weight, A, B;
};

vector<long long> calculate_costs(
    vector<int> W, vector<int> A, vector<int> B, vector<int> E) 
{
    int N = W.size();
    int Q = E.size();

    // Build artifacts
    vector<Artifact> artifacts(N);
    for (int i = 0; i < N; i++) {
        artifacts[i] = {W[i], A[i], B[i]};
    }

    // Sort artifacts by weight
    sort(artifacts.begin(), artifacts.end(), [](const Artifact &a, const Artifact &b){
        return a.weight < b.weight;
    });

    // Answers vector
    vector<long long> answers(Q);

    for (int q_idx = 0; q_idx < Q; q_idx++) {
        int D = E[q_idx];
        vector<long long> dp(N + 1, LLONG_MAX);
        dp[0] = 0; // cost of transporting 0 artifacts is 0

        for (int i = 0; i < N; i++) {
            // Option 1: send i-th artifact alone
            dp[i + 1] = min(dp[i + 1], dp[i] + artifacts[i].A);

            // Option 2: pair i-th with (i+1)-th if allowed
            if (i + 1 < N && abs(artifacts[i + 1].weight - artifacts[i].weight) <= D) {
                dp[i + 2] = min(dp[i + 2], dp[i] + artifacts[i].B + artifacts[i + 1].B);
            }
        }

        answers[q_idx] = dp[N];
    }

    return answers;
}

// Optional main to test
int main() {
    vector<int> W = {15, 12, 2, 10, 21};
    vector<int> A = {5, 4, 5, 6, 3};
    vector<int> B = {1, 2, 2, 3, 2};
    vector<int> E = {5, 9, 1};

    vector<long long> ans = calculate_costs(W, A, B, E);
    for (auto x : ans) cout << x << "\n";
}

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

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