답안 #490824

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490824 2021-11-29T12:55:01 Z Karuk 사탕 분배 (IOI21_candies) C++17
컴파일 오류
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