Submission #629194

#TimeUsernameProblemLanguageResultExecution timeMemory
629194handlenameCatfish Farm (IOI22_fish)C++17
0 / 100
1094 ms119052 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define pb push_back #define mp make_pair long long dp[3005][3005][2]; //col,height,increasing/decreasing long long pre[3005][3005]; long long max_weights(int n,int m,vector<int> x,vector<int> y,vector<int> w){ for (int i=0;i<m;i++){ x[i]++; y[i]++; pre[x[i]][y[i]]=w[i]; } for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++){ pre[i][j]+=pre[i][j-1]; } } for (int i=1;i<=n;i++){ //col for (int j=0;j<=n;j++){ //col height //calculate increasing for (int k=0;k<j;k++){ //prev col height long long cur=dp[i-1][k][0]; cur-=pre[i][k]; cur+=pre[i-1][j]-pre[i-1][k]; cur+=pre[i+1][j]; dp[i][j][0]=max(dp[i][j][0],cur); } //calculate decreasing for (int k=j+1;k<=n;k++){ //prev col height long long cur=max(dp[i-1][k][0],dp[i-1][k][1]); cur-=pre[i][j]; cur+=pre[i+1][j]; dp[i][j][1]=max(dp[i][j][1],cur); } } } long long ans=0; for (int j=1;j<=n;j++){ ans=max(ans,dp[n][j][0]); ans=max(ans,dp[n][j][1]); } 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...