Submission #1069438

#TimeUsernameProblemLanguageResultExecution timeMemory
1069438MarwenElarbiCatfish Farm (IOI22_fish)C++17
35 / 100
1068 ms2097152 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define pb push_back #define fi first #define se second const int nax = 3e3+5; vector<long long> tab[nax]; 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; int grid[n+1][n+1]; memset(grid,0,sizeof grid); long long pre[n+1][n+1]; memset(pre,0,sizeof pre); for (int i = 0; i < m; ++i) { grid[X[i]][Y[i]+1]+=W[i]; } 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 dp[n+1][n+1][2]; memset(dp,0,sizeof dp); 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],dp[i-1][k][1]+pre[i-1][j]-pre[i-1][k]); dp[i][j][1]=max(dp[i][j][1],dp[i-1][0][0]); }else if(k>j){ dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][1]+pre[i][k]-pre[i][j]); dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i][k]-pre[i][j]); }else if (j==0){ dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]}); dp[i][j][1]=max({dp[i][j][1],dp[i-1][j][0],dp[i-1][j][1]}); }/*else{ dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]}); dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][1]); }*/ ans=max({ans,dp[i][j][0],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...