Submission #780778

#TimeUsernameProblemLanguageResultExecution timeMemory
780778Mouad_oujCatfish Farm (IOI22_fish)C++17
0 / 100
823 ms2097152 KiB
#include "fish.h"//sub5 #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][n+1],ans=0,dp[n][n+1][n+1]; for(int a=0;a<n;a++) { for(int b=0;b<n+1;b++) { tab[a][b]=0; for(int c=0;c<n+1;c++) dp[a][b][c]=0; } } for(int a=0;a<m;a++) tab[x[a]][y[a]+1]=w[a]; for(int a=0;a<n;a++) { for(int b=1;b<n+1;b++) tab[a][b]+=tab[a][b-1]; } for(int a=0;a<n+1;a++) { for(int b=0;b<n+1;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<n+1;a++) { int d=0,cur=0; for(int e=0;e<n+1;e++) { if(dp[c-1][e][a]>=cur) { cur=dp[c-1][e][a]; d=e; } } for(int b=0;b<n+1;b++) { 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<n+1;a++) { for(int b=0;b<n+1;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...