#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);
}
c++;
r = min(n, r + 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 |
16 ms |
11352 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '79354156169497' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
31 ms |
13360 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '174836637484219' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Runtime error |
4 ms |
348 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
18780 KB |
Output is correct |
10 |
Correct |
4 ms |
33372 KB |
Output is correct |
11 |
Correct |
2 ms |
18896 KB |
Output is correct |
12 |
Correct |
3 ms |
33116 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
33116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
18780 KB |
Output is correct |
10 |
Correct |
4 ms |
33372 KB |
Output is correct |
11 |
Correct |
2 ms |
18896 KB |
Output is correct |
12 |
Correct |
3 ms |
33116 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
33116 KB |
Output is correct |
15 |
Correct |
4 ms |
33116 KB |
Output is correct |
16 |
Correct |
2 ms |
10588 KB |
Output is correct |
17 |
Correct |
12 ms |
32984 KB |
Output is correct |
18 |
Correct |
12 ms |
32860 KB |
Output is correct |
19 |
Correct |
14 ms |
35020 KB |
Output is correct |
20 |
Correct |
12 ms |
34908 KB |
Output is correct |
21 |
Correct |
12 ms |
34884 KB |
Output is correct |
22 |
Correct |
20 ms |
36956 KB |
Output is correct |
23 |
Correct |
6 ms |
33464 KB |
Output is correct |
24 |
Correct |
10 ms |
34396 KB |
Output is correct |
25 |
Correct |
4 ms |
33116 KB |
Output is correct |
26 |
Correct |
6 ms |
33628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
18780 KB |
Output is correct |
10 |
Correct |
4 ms |
33372 KB |
Output is correct |
11 |
Correct |
2 ms |
18896 KB |
Output is correct |
12 |
Correct |
3 ms |
33116 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
4 ms |
33116 KB |
Output is correct |
15 |
Correct |
4 ms |
33116 KB |
Output is correct |
16 |
Correct |
2 ms |
10588 KB |
Output is correct |
17 |
Correct |
12 ms |
32984 KB |
Output is correct |
18 |
Correct |
12 ms |
32860 KB |
Output is correct |
19 |
Correct |
14 ms |
35020 KB |
Output is correct |
20 |
Correct |
12 ms |
34908 KB |
Output is correct |
21 |
Correct |
12 ms |
34884 KB |
Output is correct |
22 |
Correct |
20 ms |
36956 KB |
Output is correct |
23 |
Correct |
6 ms |
33464 KB |
Output is correct |
24 |
Correct |
10 ms |
34396 KB |
Output is correct |
25 |
Correct |
4 ms |
33116 KB |
Output is correct |
26 |
Correct |
6 ms |
33628 KB |
Output is correct |
27 |
Correct |
87 ms |
250804 KB |
Output is correct |
28 |
Correct |
50 ms |
76884 KB |
Output is correct |
29 |
Correct |
128 ms |
230512 KB |
Output is correct |
30 |
Correct |
126 ms |
263252 KB |
Output is correct |
31 |
Correct |
135 ms |
263252 KB |
Output is correct |
32 |
Correct |
63 ms |
67924 KB |
Output is correct |
33 |
Correct |
128 ms |
263252 KB |
Output is correct |
34 |
Correct |
133 ms |
263508 KB |
Output is correct |
35 |
Correct |
45 ms |
253968 KB |
Output is correct |
36 |
Correct |
88 ms |
117840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Runtime error |
4 ms |
348 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
11352 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '79354156169497' |
2 |
Halted |
0 ms |
0 KB |
- |