#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 3002;
int64 dp [maxn][maxn][2];
int64 mx [maxn];
int64 p [maxn][maxn];
int lim = 8;
int64 max_weights(int n, int m, vector<int> x, vector<int> y,
vector<int> w) {
lim = min(lim, n);
for (int i = 0; i < m; i++) {
p[++x[i]][++y[i]] = w[i];
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
p[i][j]+=p[i][j-1];
}
}
for (int i = 2; i <= n; i++){
for (int j = 0; j <= n; j++){
dp[i][j][0] = mx[i-2] + p[i-1][j];
for (int k = j; k <= n; k++){
dp[i][j][0] = max(dp[i][j][0], max(dp[i-1][k][0], dp[i-1][k][1]) + p[i][k] - p[i][j]);
}
for (int k = 0; k <= j; k++){
dp[i][j][1] = max(dp[i][j][1], dp[i-1][k][1] + p[i-1][j] - p[i-1][k]);
}
mx[i] = max({mx[i], dp[i][j][0], dp[i][j][1]});
}
}
return mx[n];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
115964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
1103 ms |
118344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
107776 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 |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
2004 KB |
Output is correct |
10 |
Correct |
40 ms |
4808 KB |
Output is correct |
11 |
Incorrect |
7 ms |
2036 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
2004 KB |
Output is correct |
10 |
Correct |
40 ms |
4808 KB |
Output is correct |
11 |
Incorrect |
7 ms |
2036 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
2004 KB |
Output is correct |
10 |
Correct |
40 ms |
4808 KB |
Output is correct |
11 |
Incorrect |
7 ms |
2036 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
107776 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
115964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |