#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;
return memo[x][last][lastlast]=0;
}
memo[x][last][lastlast] = 0;
for (int i = 0; i < min(20LL,N+1); i++)
{
int c=dp(x+1, i, last);
if(x>0) for (int y = last; y < max(i,lastlast); y++) c+=a[x-1][y];
if(x==N-1) for (int y = i; y < last; y++) c+=a[x][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;
}
Compilation message
fish.cpp: In function 'long long int dp(long long int, long long int, long long int)':
fish.cpp:11:9: warning: unused variable 'c' [-Wunused-variable]
11 | int c=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
777 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
801 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
763 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
23 ms |
28468 KB |
Output is correct |
10 |
Correct |
122 ms |
218280 KB |
Output is correct |
11 |
Correct |
24 ms |
28248 KB |
Output is correct |
12 |
Correct |
114 ms |
218152 KB |
Output is correct |
13 |
Correct |
7 ms |
4184 KB |
Output is correct |
14 |
Correct |
113 ms |
218192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
23 ms |
28468 KB |
Output is correct |
10 |
Correct |
122 ms |
218280 KB |
Output is correct |
11 |
Correct |
24 ms |
28248 KB |
Output is correct |
12 |
Correct |
114 ms |
218152 KB |
Output is correct |
13 |
Correct |
7 ms |
4184 KB |
Output is correct |
14 |
Correct |
113 ms |
218192 KB |
Output is correct |
15 |
Incorrect |
115 ms |
218196 KB |
1st lines differ - on the 1st token, expected: '299', found: '19' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
23 ms |
28468 KB |
Output is correct |
10 |
Correct |
122 ms |
218280 KB |
Output is correct |
11 |
Correct |
24 ms |
28248 KB |
Output is correct |
12 |
Correct |
114 ms |
218152 KB |
Output is correct |
13 |
Correct |
7 ms |
4184 KB |
Output is correct |
14 |
Correct |
113 ms |
218192 KB |
Output is correct |
15 |
Incorrect |
115 ms |
218196 KB |
1st lines differ - on the 1st token, expected: '299', found: '19' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
763 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
777 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |