#include <bits/stdc++.h>
#include "fish.h"
#define ll long long
using namespace std;
ll w[305][10];
ll dp[305][10][10];
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
for(int i=0; i<M; i++){
w[X[i]+1][Y[i]+1]=W[i];
}
for(int i=1; i<=N; i++){
for(int j=2; j<=9; j++){
w[i][j]+=w[i][j-1];
}
}
for(int i=2; i<=N; i++){
for(int h1=0; h1<=9; h1++){
for(int h2=0; h2<=9; h2++){
for(int h3=0; h3<=9; h3++){
ll p=dp[i-1][h2][h3];
if(h1>h3 && h1>h2) p+=w[i-1][h1]-w[i-1][max(h2,h3)];
if(h2>h1) p+=w[i][h2]-w[i][h1];
dp[i][h1][h2]=max(p,dp[i][h1][h2]);
if(i==2) break;
}
//cout<<i<<' '<<h1<<' '<<h2<<' '<<dp[i][h1][h2]<<'\n';
}
}
}
ll b=0;
for(int h1=0; h1<=9; h1++){
for(int h2=0; h2<=9; h2++){
b=max(b,dp[N][h1][h2]);
}
}
return b;
}
# | 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... |