#include "fish.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 300 + 10;
int n, m;
int t[MAXN][MAXN];
bool bl[MAXN][10][10][10];
llong dp[MAXN][10][10][10];
llong f(int idx, int curr, int last1, int last2)
{
if (idx == n + 1)
{
return 0;
}
if (bl[idx][curr][last1][last2])
{
return dp[idx][curr][last1][last2];
}
bl[idx][curr][last1][last2] = true;
dp[idx][curr][last1][last2] = f(idx + 1, 0, curr, last1);
if (curr < 8)
{
llong add = t[idx + 1][curr + 1];
if (last2 < curr + 1 && last1 < curr + 1)
{
add += t[idx - 1][curr + 1];
}
if (last1 >= curr + 1)
{
add -= t[idx][curr + 1];
}
dp[idx][curr][last1][last2] = std::max(dp[idx][curr][last1][last2], f(idx, curr + 1, last1, last2) + add);
}
return dp[idx][curr][last1][last2];
}
llong max_weights(int N, int M, std::vector <int> X, std::vector <int> Y, std::vector <int> W)
{
n = N; m = M;
for (int i = 0 ; i < m ; ++i)
{
t[X[i] + 1][Y[i] + 1] = W[i];
}
return f(1, 0, 0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
5196 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '719634335344' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
50 ms |
7208 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '788042210426' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
1748 KB |
Output is correct |
10 |
Correct |
8 ms |
3388 KB |
Output is correct |
11 |
Correct |
3 ms |
1748 KB |
Output is correct |
12 |
Correct |
6 ms |
3284 KB |
Output is correct |
13 |
Correct |
3 ms |
1076 KB |
Output is correct |
14 |
Correct |
6 ms |
3388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
1748 KB |
Output is correct |
10 |
Correct |
8 ms |
3388 KB |
Output is correct |
11 |
Correct |
3 ms |
1748 KB |
Output is correct |
12 |
Correct |
6 ms |
3284 KB |
Output is correct |
13 |
Correct |
3 ms |
1076 KB |
Output is correct |
14 |
Correct |
6 ms |
3388 KB |
Output is correct |
15 |
Incorrect |
5 ms |
3284 KB |
1st lines differ - on the 1st token, expected: '299', found: '8' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
1748 KB |
Output is correct |
10 |
Correct |
8 ms |
3388 KB |
Output is correct |
11 |
Correct |
3 ms |
1748 KB |
Output is correct |
12 |
Correct |
6 ms |
3284 KB |
Output is correct |
13 |
Correct |
3 ms |
1076 KB |
Output is correct |
14 |
Correct |
6 ms |
3388 KB |
Output is correct |
15 |
Incorrect |
5 ms |
3284 KB |
1st lines differ - on the 1st token, expected: '299', found: '8' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
5196 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '719634335344' |
2 |
Halted |
0 ms |
0 KB |
- |