#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
vector<vector<long long>> grid(N+1, vector<long long>(N + 1));
for (int i = 0; i <= N; i++)
grid[i].assign(N + 1, 0);
long long dp[N][N + 1][N + 1];
long long vp[N][N + 1][N + 1];
for (int i = 0; i < M; i++) {
grid[X[i] ][Y[i]+1] += W[i];
}
for (int i = 0; i <=N; i++) {
for (int j = 1; j <= N; j++) {
grid[i][j] += grid[i][j - 1];
}
}
for (int i = 0; i <=N; i++) {
for (int j = 0; j <= N; j++) {
dp[0][i][j] = max(0LL, grid[0][j] - grid[0][i]);
if (i > 0)
vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0LL,grid[1][i]-grid[1][j]));
else
vp[0][i][j] = dp[0][i][j]+max(0LL,grid[1][i]-grid[1][j]);
}
}
for (int i = 1; i < N; i++) {
for (int j = 0; j <= N; j++) {
for (int g = 0; g <= N; g++) {
if(g>j){
dp[i][j][g]=grid[i][g]-grid[i][j]+vp[i-1][N][j];
}
else{
dp[i][j][g]=vp[i-1][N][j];
}
if (j > 0)
vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0LL,grid[i+1][j]-grid[i+1][g]));
else
vp[i][j][g] = dp[i][j][g]+max(0LL,grid[i+1][j]-grid[i+1][g]);
}
}
}
long long ans=0;
for(int i=0;i<=N;i++){
ans=max(ans,dp[N-1][i][0]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
792 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
848 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
786 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
34 ms |
53984 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '326664473535' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
34 ms |
53984 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '326664473535' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
34 ms |
53984 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '326664473535' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
786 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
792 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |