Submission #858718

# Submission time Handle Problem Language Result Execution time Memory
858718 2023-10-09T05:31:06 Z deepaung Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"

#include <bits/stdc++.h>

#define int long long

using namespace std;

int sumtop[3003][3003], sumbot[3003][3003];
int dp[3003][3003];

long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {

    for (int i = 0; i < M; i++) {
        sumtop[X[i]+1][Y[i]+1] += W[i];
        sumbot[X[i]+1][Y[i]+1] += W[i];
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) sumtop[i][j] += sumtop[i][j-1];
        for (int j = N; j >= 1; j--) sumbot[i][j] += sumbot[i][j-1];
    }
  
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= N; k++) {
                dp[i][j] = max(
                    dp[i][j], 
                    dp[i-1][k] - sumbot[i][min(j, k)] + sumbot[i+1][k] + (k > j ? sumbot[i-1][k] - sumbot[i-1][j] : 0)
                );
            }
        }
    }

    int mx = 0;
    for (int j = 1; j <= N; j++) {
        mx = max(mx, dp[N][j]);
    }

    return mx;

}

Compilation message

/usr/bin/ld: /tmp/ccSnmnZN.o: in function `main':
grader.cpp:(.text.startup+0x25e): 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