#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
using ll = long long;
int a[3030][3030];
/*
0 -> Increasing
1 -> Decreasing
2 -> No Poles
*/
ll dp[3][3030][3030];
int n, m;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N, m = M;
for (int i = 0;i < m;i++) {
a[X[i] + 1][Y[i] + 1] = W[i];
}
for (int j = 1;j <= n;j++) dp[2][1][j] = dp[2][1][j - 1] + a[i][j];
ll mx;
for (int i = 2;i <= n;i++) {
// h[i-1] <= h[i] (1)
mx = 0;
for (int j = 0;j <= n;j++) {
mx = max({ mx + a[i - 1][j], dp[0][i - 1][j], dp[2][i - 1][j] });
dp[0][i][j] = mx;
}
// h[i-1] >= h[i] (2)
mx = 0;
for (int j = n;j >= 0;j--) {
dp[1][i][j] = mx;
mx = max({ mx + a[i][j],dp[0][i - 1][j], dp[1][i - 1][j] });
}
// (3)
mx = 0;
ll sum = 0;
for (int j = 0;j <= n;j++) {
sum += a[i][j];
mx = max({ mx, dp[0][i - 1][j], dp[1][i - 1][j] });
dp[2][i][j] = mx + sum;
}
}
ll ans = 0;
for (int i = 1;i <= n;i++) {
for (int j = 0;j <= n;j++) {
ans = max(ans, dp[0][i][j]);
ans = max(ans, dp[1][i][j]);
}
}
return ans;
}
Compilation message
fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:18:66: error: 'i' was not declared in this scope
18 | for (int j = 1;j <= n;j++) dp[2][1][j] = dp[2][1][j - 1] + a[i][j];
| ^