Submission #490824

# Submission time Handle Problem Language Result Execution time Memory
490824 2021-11-29T12:55:01 Z Karuk Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(int c[], int l[], int r[], int v[])
{
    int n=sizeof(c);
    int q=sizeof(l);
    vector<int>ans(n,0);
    for(int i=0;i<q;i++)
    {
        for(int j=l[i];j<=r[i];j++)
        {
            if(v[i]>0)ans[j]=min(c[i],ans[j]+v[i]);
            else ans[j]=max(0,ans[j]+v[i]);
        }
    }
    return ans;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(int*, int*, int*, int*)':
candies.cpp:5:18: warning: 'sizeof' on array function parameter 'c' will return size of 'int*' [-Wsizeof-array-argument]
    5 |     int n=sizeof(c);
      |                 ~^~
candies.cpp:3:36: note: declared here
    3 | vector<int> distribute_candies(int c[], int l[], int r[], int v[])
      |                                ~~~~^~~
candies.cpp:6:18: warning: 'sizeof' on array function parameter 'l' will return size of 'int*' [-Wsizeof-array-argument]
    6 |     int q=sizeof(l);
      |                 ~^~
candies.cpp:3:45: note: declared here
    3 | vector<int> distribute_candies(int c[], int l[], int r[], int v[])
      |                                         ~~~~^~~
/usr/bin/ld: /tmp/ccjiHxGx.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