Submission #628638

#TimeUsernameProblemLanguageResultExecution timeMemory
628638MateGiorbelidzeCatfish Farm (IOI22_fish)C++17
52 / 100
530 ms218864 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll a[3001][3001] , b[3001][3001] , d[3001][3001]; int n , m; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { n = N; m = M; for (int i = 0; i < m; i++) { d[Y[i] + 1][X[i] + 1] = W[i]; } for (int j = 1; j <= n; j++) { if (j != n) { a[1][j] = b[1][j - 1] + d[1][j]; for (int i = 2; i <= n; i++) { a[i][j] = max(a[i - 1][j] , a[i - 1][j - 1]) + d[i][j]; } } if (j == 1) continue; b[n][j] = max(a[n][j - 2] , b[1][j - 2]) + d[n][j]; for (int i = n - 1; i > 0; i--) { b[i][j] = max(b[i + 1][j] , b[i + 1][j - 1]) + d[i][j]; } } ll ans = max(a[n][n - 1] , b[1][n]); 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...