Submission #1075569

#TimeUsernameProblemLanguageResultExecution timeMemory
1075569UmairAhmadMirzaCatfish Farm (IOI22_fish)C++17
0 / 100
31 ms7256 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=305; ll dp[N][N]; ll sm[N][N]; long long max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W) { for(int i=0;i<m;i++) sm[X[i]+1][Y[i]+1]+=W[i]; for (int i = 1; i <=n; ++i) for(int j=1;j<=n;++j) sm[i][j]+=sm[i][j-1]; for(int i=2;i<=n;i++) for(int k=0;k<=n;k++){ for(int p=k+1;p<=n;p++) dp[i][k]=max(dp[i][k],dp[i-1][p]+sm[i][p]-sm[i][k]); for(int p=0;p<=k;p++) dp[i][k]=max(dp[i][k],dp[i-1][p]); if(i==2) dp[i][k]=max(dp[i][k],sm[i-1][k]); if(i>2){ for(int p=0;p<=n;p++) dp[i][k]=max(dp[i][k],dp[i-2][p]+sm[i-1][max(p,k)]); } // cout<<dp[i][k]<<' '; // if(k==n) // cout<<endl; } ll ans=0; for(int i=0;i<=n;i++) ans=max(ans,dp[n][i]); 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...