#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long f_pref[305][305], dp1[305][305], dp2[305][305], dp_pref[305][305], dp_suff[305][305];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
for(int i = 0; i < M; i++) f_pref[X[i]][Y[i] + 1] = W[i];
for(int i = 0; i < N; i++) for(int j = 1; j <= N; j++) f_pref[i][j] += f_pref[i][j - 1];
for(int l = 1; l < N; l++) {
for(int i = 0; i <= N; i++) {
for(int j = 0; j <= N; j++) {
if(i <= j) dp1[i][j] = dp_pref[j][N] + f_pref[l][j] - f_pref[l][i];
else{
dp1[i][j] = dp_pref[j][j] + f_pref[l - 1][i] - f_pref[l - 1][j];
dp1[i][j] = max(dp1[i][j], dp_suff[j][i]);
if(!j) for(int k = j; k < i; k++) dp1[i][j] = max(dp1[i][j], dp2[j][k] + f_pref[l - 1][i] - f_pref[l - 1][k]);
}
}
}
swap(dp1, dp2);
memset(dp1, 0, sizeof(dp1));
memcpy(dp_pref, dp2, sizeof(dp2));
memcpy(dp_suff, dp2, sizeof(dp2));
for(int i = 0; i <= N; i++) for(int j = 1; j <= N; j++) dp_pref[i][j] = max(dp_pref[i][j-1], dp_pref[i][j]);
for(int i = 0; i <= N; i++) for(int j = N; j--;) dp_suff[i][j] = max(dp_suff[i][j + 1], dp_suff[i][j]);
}
long long ans = 0;
for(int i = 0; i <= N; i++) for(int j = 0; j <= N; j++) ans = max(ans, dp2[i][j]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
5724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Runtime error |
43 ms |
9768 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
2 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
2 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3164 KB |
Output is correct |
9 |
Correct |
42 ms |
3676 KB |
Output is correct |
10 |
Correct |
188 ms |
4148 KB |
Output is correct |
11 |
Correct |
40 ms |
3684 KB |
Output is correct |
12 |
Correct |
189 ms |
3928 KB |
Output is correct |
13 |
Correct |
12 ms |
3416 KB |
Output is correct |
14 |
Correct |
189 ms |
4084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
2 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
2 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3164 KB |
Output is correct |
9 |
Correct |
42 ms |
3676 KB |
Output is correct |
10 |
Correct |
188 ms |
4148 KB |
Output is correct |
11 |
Correct |
40 ms |
3684 KB |
Output is correct |
12 |
Correct |
189 ms |
3928 KB |
Output is correct |
13 |
Correct |
12 ms |
3416 KB |
Output is correct |
14 |
Correct |
189 ms |
4084 KB |
Output is correct |
15 |
Correct |
191 ms |
3932 KB |
Output is correct |
16 |
Correct |
13 ms |
3416 KB |
Output is correct |
17 |
Correct |
200 ms |
5916 KB |
Output is correct |
18 |
Correct |
195 ms |
5716 KB |
Output is correct |
19 |
Correct |
211 ms |
5720 KB |
Output is correct |
20 |
Correct |
203 ms |
5868 KB |
Output is correct |
21 |
Correct |
202 ms |
5724 KB |
Output is correct |
22 |
Correct |
206 ms |
7684 KB |
Output is correct |
23 |
Correct |
194 ms |
4412 KB |
Output is correct |
24 |
Correct |
200 ms |
5256 KB |
Output is correct |
25 |
Correct |
186 ms |
3932 KB |
Output is correct |
26 |
Correct |
189 ms |
4384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
2 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
2 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3164 KB |
Output is correct |
9 |
Correct |
42 ms |
3676 KB |
Output is correct |
10 |
Correct |
188 ms |
4148 KB |
Output is correct |
11 |
Correct |
40 ms |
3684 KB |
Output is correct |
12 |
Correct |
189 ms |
3928 KB |
Output is correct |
13 |
Correct |
12 ms |
3416 KB |
Output is correct |
14 |
Correct |
189 ms |
4084 KB |
Output is correct |
15 |
Correct |
191 ms |
3932 KB |
Output is correct |
16 |
Correct |
13 ms |
3416 KB |
Output is correct |
17 |
Correct |
200 ms |
5916 KB |
Output is correct |
18 |
Correct |
195 ms |
5716 KB |
Output is correct |
19 |
Correct |
211 ms |
5720 KB |
Output is correct |
20 |
Correct |
203 ms |
5868 KB |
Output is correct |
21 |
Correct |
202 ms |
5724 KB |
Output is correct |
22 |
Correct |
206 ms |
7684 KB |
Output is correct |
23 |
Correct |
194 ms |
4412 KB |
Output is correct |
24 |
Correct |
200 ms |
5256 KB |
Output is correct |
25 |
Correct |
186 ms |
3932 KB |
Output is correct |
26 |
Correct |
189 ms |
4384 KB |
Output is correct |
27 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
5724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |