Submission #469789

# Submission time Handle Problem Language Result Execution time Memory
469789 2021-09-01T19:00:40 Z FirasMesbeh Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int N=20005;
int c[N]; int v[N]; int l[N]; int r[N]; int a[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin>>n;
    for(int i=0;i<n;i++) cin>>c[i];
    int q;
    cin>>q;
    for(int i=0;i<q;i++) cin>>l[i]>>r[i]>>v[i];
    for(int i=0;i<q;i++)
    {
        for(int j=l[i];j<=r[i];j++)
        {
            if(v[i]>0) a[j]=min(c[j],a[j]+v[i]);
            else a[j]=max(0,a[j]+v[i]);
        }
    }
    for(int i=0;i<n;i++) cout<<a[i]<<' ';
}

Compilation message

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