#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 < 5)
{
llong add = t[curr + 1][idx + 1];
if (last2 < curr + 1 && last1 < idx - 1)
{
add += t[curr + 1][idx - 1];
}
if (last1 >= curr + 1)
{
add -= t[curr + 1][idx];
}
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[Y[i] + 1][X[i] + 1] = W[i];
}
return f(1, 0, 0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
24 ms |
4456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Runtime error |
52 ms |
8396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
308 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
308 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
308 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
24 ms |
4456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |