#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3002;
const int MAX_M = 3e5;
const long long INF = 1e18;
int costCell[MAX_N][MAX_N];
long long dp[MAX_N][MAX_N], dpLower[MAX_N][MAX_N], spX[MAX_N][MAX_N];
long long max_weights( int n, int m, vector <int> X, vector <int> Y, vector <int> W ) {
for ( int i = 0; i < m; i++ ) {
X[i]++;
Y[i]++;
costCell[X[i]][Y[i]] = W[i];
}
for ( int x = 1; x <= n; x++ ) {
for ( int y = 1; y <= n; y++ )
spX[x][y] = spX[x][y - 1] + costCell[x][y];
}
for ( int crtY = 1; crtY <= n; crtY++ )
dp[0][crtY] = dpLower[0][crtY] = -INF;
dp[0][0] = dpLower[0][0] = 0;
for ( int x = 1; x <= n + 1; x++ ) {
for ( int crtY = 0; crtY <= n; crtY++ ) {
dp[x][crtY] = dpLower[x][crtY] = -INF;
for ( int prevY = 0; prevY <= crtY; prevY++ ) {
dpLower[x][crtY] = max( dpLower[x][crtY], dpLower[x - 1][prevY] + spX[x - 1][crtY] - spX[x - 1][prevY] );
if ( x >= 2 )
dpLower[x][crtY] = max( dpLower[x][crtY], dpLower[x - 2][prevY] + spX[x - 1][crtY] );
dp[x][crtY] = max( dp[x][crtY], dpLower[x - 1][prevY] + spX[x - 1][crtY] - spX[x - 1][prevY] );
if ( x >= 2 )
dp[x][crtY] = max( dp[x][crtY], dp[x - 2][prevY] + spX[x - 1][crtY] );
}
for ( int prevY = crtY; prevY <= n; prevY++ ) {
if ( x >= 2 )
dpLower[x][crtY] = max( dpLower[x][crtY], dpLower[x - 2][prevY] + spX[x - 1][prevY] );
dp[x][crtY] = max( dp[x][crtY], dp[x - 1][prevY] + spX[x][prevY] - spX[x][crtY] );
if ( x >= 2 )
dp[x][crtY] = max( dp[x][crtY], dp[x - 2][prevY] + spX[x - 1][prevY] );
}
//printf( "%lld ", dpLower[x][crtY] );
}
//printf( "\n" );
}
return dp[n + 1][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
601 ms |
154556 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Runtime error |
620 ms |
158488 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
639 ms |
150636 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6600 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
10 ms |
15608 KB |
Output is correct |
10 |
Correct |
67 ms |
24964 KB |
Output is correct |
11 |
Incorrect |
11 ms |
15608 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '278323186206' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6600 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
10 ms |
15608 KB |
Output is correct |
10 |
Correct |
67 ms |
24964 KB |
Output is correct |
11 |
Incorrect |
11 ms |
15608 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '278323186206' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6600 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
10 ms |
15608 KB |
Output is correct |
10 |
Correct |
67 ms |
24964 KB |
Output is correct |
11 |
Incorrect |
11 ms |
15608 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '278323186206' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
639 ms |
150636 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
601 ms |
154556 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |