Submission #438949

#TimeUsernameProblemLanguageResultExecution timeMemory
438949jlozano254Distributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#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 (stderr)

/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