Submission #1062211

#TimeUsernameProblemLanguageResultExecution timeMemory
1062211MarwenElarbiCatfish Farm (IOI22_fish)C++17
0 / 100
924 ms2097152 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define pb push_back #define ll long long #define fi first #define se second long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { int n=N;int m=M; long long dp[n][n][2]; memset(dp,0,sizeof dp); long long grid[n][n]; memset(grid,0,sizeof grid); for (int i = 0; i < m; ++i) { grid[X[i]][Y[i]]=W[i]; } long long pre[n][n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { pre[i][j]=(j ? pre[i][j-1] : 0)+grid[i][j]; } } long long ans=0; for (int i = 1; i < n; ++i) { for (int j = 0; j < n; ++j) { for (int k = 0; k < n; ++k) { if(k>j){ dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1])+pre[i][k]-(j>0 ? pre[i][j-1] : 0ll)); }else if(k<j){ dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i-1][j]-(k>0 ? pre[i-1][k-1] : 0ll)); }else { dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]); dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1])); } } ans=max(ans,dp[i][j][0]); ans=max(ans,dp[i][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...