#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll up[3010][3010];
ll down[3010][3010];
ll s[3010][3010];
ll dp[3010];
ll max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
for(int i=0;i<M;i++){
s[X[i]][Y[i]+1]+=W[i];
}
for(int i=0;i<N;i++)
for(int j=1;j<=N;j++)
s[i][j]+=s[i][j-1];
for(int i=1;i<N;i++){
for(int j=0;j<=N;j++){
if(i==1) up[i][j]=s[i-1][j];
else up[i][j]=dp[i-2]+s[i-1][j];
for(int k=0;k<=j;k++) up[i][j]=max(up[i][j],up[i-1][k]-s[i-1][k]+s[i-1][j]);
for(int k=j;k<=N;k++) down[i][j]=max(down[i][j],max(down[i-1][k],up[i-1][k])+s[i][k]-s[i][j]);
//printf("%d %d %lld %lld\n",i,j,up[i][j],down[i][j]);
dp[i]=max(dp[i],max(up[i][j],down[i][j]));
}
}
return dp[N-1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
116752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
119580 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
110268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
2644 KB |
Output is correct |
10 |
Correct |
36 ms |
6036 KB |
Output is correct |
11 |
Correct |
7 ms |
2656 KB |
Output is correct |
12 |
Correct |
38 ms |
6052 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
35 ms |
5964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
2644 KB |
Output is correct |
10 |
Correct |
36 ms |
6036 KB |
Output is correct |
11 |
Correct |
7 ms |
2656 KB |
Output is correct |
12 |
Correct |
38 ms |
6052 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
35 ms |
5964 KB |
Output is correct |
15 |
Correct |
38 ms |
5996 KB |
Output is correct |
16 |
Correct |
2 ms |
1364 KB |
Output is correct |
17 |
Correct |
49 ms |
7060 KB |
Output is correct |
18 |
Correct |
47 ms |
6992 KB |
Output is correct |
19 |
Correct |
46 ms |
6988 KB |
Output is correct |
20 |
Correct |
45 ms |
6988 KB |
Output is correct |
21 |
Correct |
46 ms |
7024 KB |
Output is correct |
22 |
Correct |
65 ms |
8136 KB |
Output is correct |
23 |
Correct |
37 ms |
6208 KB |
Output is correct |
24 |
Correct |
42 ms |
6612 KB |
Output is correct |
25 |
Correct |
36 ms |
5980 KB |
Output is correct |
26 |
Correct |
39 ms |
6208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
2644 KB |
Output is correct |
10 |
Correct |
36 ms |
6036 KB |
Output is correct |
11 |
Correct |
7 ms |
2656 KB |
Output is correct |
12 |
Correct |
38 ms |
6052 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
35 ms |
5964 KB |
Output is correct |
15 |
Correct |
38 ms |
5996 KB |
Output is correct |
16 |
Correct |
2 ms |
1364 KB |
Output is correct |
17 |
Correct |
49 ms |
7060 KB |
Output is correct |
18 |
Correct |
47 ms |
6992 KB |
Output is correct |
19 |
Correct |
46 ms |
6988 KB |
Output is correct |
20 |
Correct |
45 ms |
6988 KB |
Output is correct |
21 |
Correct |
46 ms |
7024 KB |
Output is correct |
22 |
Correct |
65 ms |
8136 KB |
Output is correct |
23 |
Correct |
37 ms |
6208 KB |
Output is correct |
24 |
Correct |
42 ms |
6612 KB |
Output is correct |
25 |
Correct |
36 ms |
5980 KB |
Output is correct |
26 |
Correct |
39 ms |
6208 KB |
Output is correct |
27 |
Execution timed out |
1090 ms |
75656 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
110268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
116752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |