답안 #438949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438949 2021-06-29T01:19:03 Z jlozano254 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/*
Time O(n2)
Space O(n)
*/
/*
Day Box 0 Box 1 Box 2
0   10    15    13
1   0     4     13
*/
vector<int> dis_candies(int n, int q, vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    vector<int> candies(n);

    for (int i = 0; i <= n; ++i)
    {
        for (int j = l[i]; j <= r[i]; ++j)
        {
            if (v[i] < 0) {
                candies[j] = max(0, candies[j] + v[i]);
            }
            else {
                candies[j] = min(c[j], candies[j] + v[i]);
            }
        }
    }

    return candies;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin.precision(10);

    int aux, aux2, aux3;
    int n, q;
    vector<int> c, l, r, v;

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> aux;
        c.push_back(aux);
    }

    cin >> q;

    for (int i = 0; i < q; ++i) {
        cin >> aux >> aux2 >> aux3;
        l.push_back(aux);
        r.push_back(aux2);
        v.push_back(aux3);
    }

    auto candies = dis_candies(n, q, c, l, r, v);
    for (auto c : candies) cout << c << " ";

    //cout << endl;
    //cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << " seconds" << endl;
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccKym1rA.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccX6g2dx.o:candies.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKym1rA.o: in function `main':
grader.cpp:(.text.startup+0x30e): undefined reference to `distribute_candies(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status