답안 #1105660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105660 2024-10-27T08:32:05 Z KDM_Dvali 나일강 (IOI24_nile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<ll> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
    int n = W.size();
    int q = E.size();
    vector<ll> R(q, 0);
    ll sb = 0;

    for (int i = 0; i < n; i++) {
        sb += B[i];
    }

    for (int i = 0; i < q; i++) {
        ll d = E[i];
        long long pmin = LLONG_MAX;

        if (n % 2 == 0) {
            R[i] = sb;
            continue;
        } else {
            for (int j = 0; j < n; j++) {
                if (j % 2 == 0) {
                    pmin = min(pmin, (long long)A[j] - B[j]);
                }
                if (j > 0 && j < n - 1) {
                    if (W[j + 1] - W[j - 1] <= d) {
                        pmin = min(pmin, (long long)A[j] - B[j]);
                    }
                }
            }
        }
        R[i] = pmin + sb;
    } 
    return R;
}
int main() {
    int n, q;
    cin >> n >> q;
    
    vector<int> W(n), A(n), B(n), E(q);
    
    for (int i = 0; i < n; i++) {
        W[i] = i + 1;  
        cin >> A[i] >> B[i];
    }
    
    for (int i = 0; i < q; i++) {
        cin >> E[i];
    }
    vector<ll> result = calculate_costs(W, A, B, E);
  
    for (size_t i = 0; i < result.size(); i++) {
        cout << result[i] << " ";
    }
    cout << endl;
    
    return 0;
}

Compilation message

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