Submission #780733

#TimeUsernameProblemLanguageResultExecution timeMemory
780733Mouad_oujCatfish Farm (IOI22_fish)C++17
0 / 100
196 ms70692 KiB
#include "fish.h"//sub4 #include <bits/stdc++.h> using namespace std; long long max_weights(int n, int m,vector<int> x,vector<int> y,vector<int> w) { long long tab[n][9]={0},ans=0,dp[n][9][9]; for(int a=0;a<n;a++) { for(int b=0;b<9;b++) { tab[a][b]=0; for(int c=0;c<9;c++) dp[a][b][c]=0; } } for(int a=0;a<m;a++) tab[x[a]][y[a]]=w[a]; for(int a=0;a<n;a++) { for(int b=1;b<9;b++) tab[a][b]+=tab[a][b-1]; } for(int a=0;a<9;a++) { for(int b=0;b<9;b++) { if(a>b) dp[1][a][b]=tab[1][a]-tab[1][b]; else dp[1][a][b]=tab[0][b]-tab[0][a]; } } for(int c=2;c<n;c++) { for(int a=0;a<9;a++) { for(int b=0;b<9;b++) { for(int d=0;d<9;d++) { dp[c][a][b]=max(dp[c][a][b],dp[c-1][d][a]); if(a>b) dp[c][a][b]=max(dp[c-1][d][a]+tab[c][a]-tab[c][b],dp[c][a][b]); else if (b>d) { dp[c][a][b]=max(dp[c-1][d][a]+tab[c-1][b]-tab[c-1][max(d,a)],dp[c][a][b]); } } } } } for(int a=0;a<9;a++) { for(int b=0;b<9;b++) ans=max(ans,dp[n-1][a][b]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...