제출 #1335906

#제출 시각아이디문제언어결과실행 시간메모리
1335906enson메기 농장 (IOI22_fish)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int N, int M, int X[], int Y[], int W[]){
    bool st1 = true;
    for(int i = 0; i < M; i++) st1 &= (X[i]%2==0);
    bool st2 = true;
    for(int i = 0; i < M; i++) st2 &= (X[i]<=1);
    bool st3 = true;
    for(int i = 0; i < M; i++) st3 &= (Y[i]==0);
    if (st1){
        long long ans = 0;
        for(int i = 0; i < M; i++){
            ans += W[i];
        }
        return ans;
    }
    if (st2){
        long long e = 0, o = 0;
        for(int i = 0; i < M; i++){
            if (X[i] == 0) e += W[i];
            else o += W[i];
        }
        return max(e, o);
    }
    if (st3){
        int A[M] = {0};
        A[0] = W[0];
        A[1] = W[1];
        for(int i = 2; i < M; i++){
            A[i] = max(A[i-2] + W[i], A[i-1]);
        }
        return max(A[M-1], A[M-2]);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'long long int max_weights(int, int, int*, int*, int*)':
fish.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
/usr/bin/ld: /tmp/ccEFoJzm.o: in function `main':
grader.cpp:(.text.startup+0x25d): undefined reference to `max_weights(int, 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