#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
static long long dp[305][305];
static long long ndp[305][305];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
vector<vector<pair<int,int>>> fish(N+1);
for (int i = 0; i < M; i++) {
fish[X[i]+1].push_back({Y[i]+1, W[i]});
}
for (int h = 0; h <= N; h++) dp[0][h] = 0;
for (int c = 1; c <= N; c++) {
for (int h = 0; h <= N; h++) ndp[c][h] = LLONG_MIN;
for (int h = 0; h <= N; h++) {
for (int k = 0; k <= N; k++) {
if (dp[c-1][k] == LLONG_MIN) continue;
long long add = 0;
for (auto [y, w] : fish[c]) {
if (y >= h && k > y) {
add += w;
}
}
ndp[c][h] = max(ndp[c][h], dp[c-1][k] + add);
}
}
for (int h = 0; h <= N; h++) dp[c][h] = ndp[c][h];
}
long long ans = 0;
for (int h = 0; h <= N; h++) ans = max(ans, dp[N][h]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |