Submission #780735

#TimeUsernameProblemLanguageResultExecution timeMemory
780735Mouad_oujCatfish Farm (IOI22_fish)C++17
23 / 100
278 ms181060 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][10]={0},ans=0,dp[n][10][10]; for(int a=0;a<n;a++) { for(int b=0;b<10;b++) { tab[a][b]=0; for(int c=0;c<10;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<10;b++) tab[a][b]+=tab[a][b-1]; } for(int a=0;a<10;a++) { for(int b=0;b<10;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<10;a++) { for(int b=0;b<10;b++) { for(int d=0;d<10;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<10;a++) { for(int b=0;b<10;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...