#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
if(x==N){
int c=0;
for (int y = lastlast; y < last; y++) c+=a[x-1][y];
return memo[x][last][lastlast]=c;
}
memo[x][last][lastlast] = 0;
for (int i = 0; i < min(20LL,N); i++)
{
if(i>0&&x>0&&a[x-1][i]==0&&(x<N-1&&&a[x+1][i]==0)) continue;
int c=dp(x+1, i, last);
if(x>0) for (int y = last; y < max(i,lastlast); y++) c+=a[x-1][y];
memo[x][last][lastlast]=max(c, memo[x][last][lastlast]);
}
return memo[x][last][lastlast];
}
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
N=n; M=m;
a.resize(N, vector<int>(N,0));
memo.resize(N+1, vector<vector<int>>(N+1, vector<int>(N+1,-1)));
for (int i = 0; i < M; i++){
a[X[i]][Y[i]] = W[i];
}
int p=dp(0,0,0);
return p;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
919 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
781 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
756 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
756 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
919 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |