#include "fish.h"
#include <vector>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define sz size()
const int N2 = 303, M2 = 10;
ll a[N2][M2], pre[N2][M2];
ll dp[N2][M2][M2],dpp[N2][M2];
ll inf = 1e18;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
for(int i = 0; i < M; i++)
{
ll x = X[i]+1, y = Y[i]+1;
a[x][y] = W[i];
}
for(int i = 1; i < N2; i++)
{
for(int j = 1; j < M2; j++)
pre[i][j] = pre[i][j-1] + a[i][j];
}
for(int i = 0; i < M2; i++) {dpp[1][i] = 0; for(int j = 1; j < M2; j++) dp[1][i][j] = -inf;}
for(int i = 2; i <= N; i++)
{
for(int j = 0;j < M2; j++) dp[i][0][j] = max(dp[i][0][j], dpp[i-1][j] + pre[i][j]);
for(int j = 1; j < M2; j++)
{
for(int k = 0; k < M2; k++)
for(int l = 0; l < M2; l++)
{
ll how2 = j; ll how1 = min(how2,(ll)max(k,l));
ll me2 = k; ll me1 = min(k,j);
dp[i][j][k] = max(dp[i][j][k], dp[i-1][k][l] + pre[i-1][how2]-pre[i-1][how1] + pre[i][me2]-pre[i][me1] );
}
}
for(int j = 0; j < M2; j++) {ll mx = -inf;
for(int k = 0; k < M2; k++) mx = max(dp[i][j][k],mx); dpp[i][j] = mx;}
}
// for(int i = 1; i <= N; i++) {for(int j = 0; j < 6; j++) cout << dpp[i][j] << " "; cout << endl;}
ll mx = 0;
for(int i = 0; i < M2; i++) mx = max(mx, dpp[N][i]);
return mx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |