Submission #1073520

#TimeUsernameProblemLanguageResultExecution timeMemory
1073520ZicrusCatfish Farm (IOI22_fish)C++17
0 / 100
1040 ms2097152 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; int n, m; vector<int> x, y, w; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { n = N; m = M; x = X; y = Y; w = W; vector<vector<ll>> a(n, vector<ll>(n)); for (int i = 0; i < m; i++) { a[x[i]][y[i]] = w[i]; } vector<vector<ll>> dp(n, vector<ll>(n+1)); // TODO: 0-2 for (int j = 0; j <= min(n, 10); j++) { // i = 1 for (int j1 = 0; j1 <= j; j1++) { ll val = 0; for (int k = j1; k < j; k++) { val += a[0][k]; } for (int k = j; k < j1; k++) { val += a[0][k]; } dp[1][j] = max(dp[1][j], val); } } for (int j = 0; j <= min(n, 10); j++) { // i = 2 for (int j1 = 0; j1 <= j; j1++) { for (int j2 = 0; j2 <= j; j2++) { ll val = 0; for (int k = j2; k < max(0, j1); k++) { val += a[0][k]; } for (int k = j1; k < max(j2, j); k++) { val += a[1][k]; } dp[2][j] = max(dp[2][j], val); } } } for (int i = 3; i < n; i++) { for (int j = 0; j <= min(n, 10); j++) { for (int j1 = 0; j1 <= j; j1++) { for (int j2 = 0; j2 <= j; j2++) { for (int j3 = 0; j3 <= j; j3++) { ll val = dp[i-3][j3]; for (int k = j2; k < max(j3, j1); k++) { val += a[i-2][k]; } for (int k = j1; k < max(j2, j); k++) { val += a[i-1][k]; } dp[i][j] = max(dp[i][j], val); } } } } } ll res = 0; for (int j = 0; j <= min(n, 10); j++) { res = max(res, dp[n-1][j]); } for (int i = n-2; i >= n-5 && i >= 0; i--) { for (int j = 0; j <= min(n, 10); j++) { ll val = dp[i][j]; for (int k = 0; k < j; k++) { val += a[i+1][k]; } res = max(res, val); } } return res; } #ifdef TEST #include "grader.cpp" #endif
#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...