Submission #564770

# Submission time Handle Problem Language Result Execution time Memory
564770 2022-05-19T15:44:55 Z ngano_upat_na Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <cmath>
#include <vector>
#include "candies.h"
using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size(), q = l.size();
    vector<int> ans(n,0);
    
    for (int i=0; i<q; i++) {
        for (int j=l[i]; j<=r[i]; j++) {
            ans[j] = ((v[i] > 0) ? min(c[j], ans[j]+v[i]) : max(0, ans[j]+v[i]));
        }
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i=0; i<n; i++) cin >> c[i];
    
    int q;
    cin >> q;
    vector<int> l(q), r(q), v(q);
    for (int i=0; i<q; i++) {
        cin >> l[i] >> r[i] >> v[i];
    }
    
    vector<int> ans = distribute_candies(c, l, r, v);
    for (int i=0; i<n; i++) {
        cout << ans[i];
        if (i != n-1) cout << ' ';
    }
}

Compilation message

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