Submission #1073150

#TimeUsernameProblemLanguageResultExecution timeMemory
1073150fv3Catfish Farm (IOI22_fish)C++17
0 / 100
1081 ms2097152 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int N, M; vector<int> X, Y, W; vector<vector<ll>> ps, v, dp; ll get_score(int l, int r, int h1, int h2) { if (l < 0) return 0; const int mn_h = min(h1, h2); if (l == r - 1) return dp[l][h1] - ps[r][mn_h] - ps[l][mn_h]; if (l == r - 2) return dp[l][h1] - ps[l+1][mn_h]; return dp[l][h1]; } 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_; v = vector<vector<ll>>(N+1, vector<ll>(N)); for (int i = 0; i < M; i++) v[X[i]][Y[i]] = W[i]; ps = vector<vector<ll>>(N+1, vector<ll>(N)); for (int i = 0; i < N; i++) { ll sum = 0; for (int j = 0; j < N; j++) { sum += v[i][j]; ps[i][j] = sum; } } dp = vector<vector<ll>>(N, vector<ll>(N)); ll res = 0; for (int i = 0; i < N; i++) { dp[0][i] = ps[1][i]; res = max(res, dp[0][i]); } for (int i = 1; i < N; i++) { for (int j = 0; j < N; j++) { ll mx = 0; for (int l = i - 3; l < i; l++) { if (l < 0) continue; for (int h = 0; h < N; h++) { mx = max(mx, get_score(l, i, h, j)); } } dp[i][j] = ps[i-1][j] + ps[i+1][j] + mx; res = max(res, dp[i][j]); } } return res; }
#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...