#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;
int r = 0, c = 0;
for (int i = 0;i < m;i++) {
a[X[i] + 1][Y[i] + 1] = W[i];
r = max(r, X[i] + 1);
c = max(c, Y[i] + 1);
}
ll mx;
for (int i = 2;i <= r;i++) {
// (0)
mx = 0;
for (int j = 0;j <= c;j++) {
mx = max({ mx + a[i - 1][j], dp[0][i - 1][j], dp[2][i - 1][j] });
dp[0][i][j] = mx;
}
mx = 0;
for (int j = c;j >= 0;j--) {
mx = max(mx, dp[2][i - 1][j]);
dp[0][i][j] = max(dp[0][i][j], mx);
}
// (1)
mx = 0;
for (int j = c;j >= 0;j--) {
dp[1][i][j] = mx;
mx = max({ mx + a[i][j], dp[0][i - 1][j], dp[1][i - 1][j] });
}
// (2)
mx = 0;
for (int j = 0;j <= c;j++) {
mx += a[i][j];
dp[2][i][j] = max(dp[0][i - 1][j], dp[1][i - 1][j]) + mx;
}
}
ll ans = 0;
for (int i = 1;i <= r;i++) {
for (int j = 0;j <= c;j++) {
ans = max(ans, dp[0][i][j]);
ans = max(ans, dp[1][i][j]);
ans = max(ans, dp[2][i][j]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
6236 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
6236 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |