Submission #1247437

#TimeUsernameProblemLanguageResultExecution timeMemory
1247437fskaricaCatfish Farm (IOI22_fish)C++20
0 / 100
695 ms69800 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pii pair<int, int> const int MAX = 2010; int n, m; vector <int> vx, vy, w; ll dp[MAX][MAX][2]; int mat[MAX][MAX]; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { n = N, m = M, vx = X, vy = Y, w = W; for (int i = 0; i < m; i++) { vx[i]++; vy[i]++; mat[vx[i]][vy[i]] = w[i]; } for (int i = 2; i <= n; i++) { for (int j = 0; j <= n; j++) dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j][1]); for (int j = 0; j <= n; j++) dp[i][j][1] = max(dp[i - 1][j][0], dp[i - 1][j][1]); ll maxx = 0; for (int j = n; j >= 0; j--) { maxx = max(maxx, dp[i - 1][j][0]); dp[i][j][0] = max(dp[i][j][0], maxx); maxx += mat[i][j]; } maxx = 0; for (int j = 0; j <= n; j++) { maxx = max(maxx, dp[i - 1][j][1]); maxx += mat[i - 1][j]; dp[i][j][1] = max(dp[i][j][1], maxx); } } ll ret = 0; for (int i = 0; i <= n; i++) ret = max(ret, max(dp[n][i][0], dp[n][i][1])); return ret; }
#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...