Submission #502333

# Submission time Handle Problem Language Result Execution time Memory
502333 2022-01-05T19:12:31 Z BeefcakeCat Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include<fstream>
using namespace std;

int n = 1, q = 1;
int* distribute_candies(int c[], int l[], int r[], int v[])
{
    static int s[200000] = {0};
    for(int i = 0; i < q; i++)
    {
        for(int j = l[i]; j <= r[i]; j++)
        {
            s[j] += v[i];
            if(s[j] > c[j])
            {
                s[j] = c[j];
            }
            else if(s[j] < 0)
            {
                s[j] = 0;
            }
        }
    }
    return s;
}
int main()
{
    ifstream fin ("candies.in");
    ofstream fout ("candies.out");
    fin >> n;
    int c[n];
    int* s;
    for (int i = 0; i < n; i++)
    {
        fin >> c[i];
    }
    fin >> q;
    int l[q], r[q], v[q];
    for (int i = 0; i < q; i++)
    {
        fin >> l[i] >> r[i] >> v[i];
    }
    s = distribute_candies(c, l, r, v);
    for(int i = 0; i < n; i++)
    {
        fout << s[i] << " ";
    }
}

Compilation message

/usr/bin/ld: /tmp/cc8He4fK.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cciM3ivL.o:candies.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc8He4fK.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