Submission #625314

# Submission time Handle Problem Language Result Execution time Memory
625314 2022-08-10T03:13:59 Z il9 Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<long long> distribute_candies(vector<long long> c, vector<long long > l, vector<long long> r, vector<long long> v)
{
    vector<long long> pre(c.size()+2);
    pre[0]=0;

    int n=c.size();
    for(int i=0;i<r.size()-1;i++)
    {

        pre[l[i]+1]+=v[i];
        pre[r[i]+2]-=v[i];
    }
    for(int i=1;i<=n;i++)
    {
        pre[i]+=pre[i-1];
        //cout<<pre[i]<<" ";
    }
    for(int i=0;i<n;i++)
    {
        if(pre[i+1]>c[i])
        {
            pre[i+1]=c[i];
        }
    }
    for(int i=l[r.size()-1];i<=r[r.size()-1];i++)
    {
        long long zero=0;
        pre[i+1]=max(min(pre[i+1]+v[r.size()-1],c[i]),zero);
    }
    for(int i=0;i<n;i++)
    {
        l[i]=pre[i+1];
        //cout<<pre[i+1]<<" ";
    }
    //cout<<"\n";
    return l;
}

Compilation message

candies.cpp: In function 'std::vector<long long int> distribute_candies(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
candies.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<r.size()-1;i++)
      |                 ~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccS1YdXn.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