답안 #502338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502338 2022-01-05T19:20:37 Z BeefcakeCat 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include<fstream>
using namespace std;
int* distribute_candies(int c[], int l[], int r[], int v[])
{
    static int s[200000] = {0};
    for(int i = 0; i < sizeof(l)/sizeof(l[0]); 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;
}

Compilation message

candies.cpp: In function 'int* distribute_candies(int*, int*, int*, int*)':
candies.cpp:6:31: warning: 'sizeof' on array function parameter 'l' will return size of 'int*' [-Wsizeof-array-argument]
    6 |     for(int i = 0; i < sizeof(l)/sizeof(l[0]); i++)
      |                              ~^~
candies.cpp:3:38: note: declared here
    3 | int* distribute_candies(int c[], int l[], int r[], int v[])
      |                                  ~~~~^~~
candies.cpp:6:22: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
    6 |     for(int i = 0; i < sizeof(l)/sizeof(l[0]); i++)
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccMcZJ2Z.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