Submission #1073237

#TimeUsernameProblemLanguageResultExecution timeMemory
1073237fv3Catfish Farm (IOI22_fish)C++17
0 / 100
827 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 hl, int hr) { if (l < 0) return -(1ll << 59); return dp[l][hl]; } 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_; ps = v = vector<vector<ll>>(N+1, vector<ll>(N)); for (int i = 0; i < M; i++) v[X[i]][Y[i]] = W[i]; 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++) { res = max(res, ps[1][i]); } for (int r = 1; r < N; r++) { for (int hr = 0; hr < N; hr++) { ll mx = ps[r-1][hr]; for (int hl = 0; hl < N; hl++) mx = max(mx, get_score(r-2, r, hl, hr) + ps[r-1][max(hl, hr)]); for (int hl = 0; hl < N; hl++) mx = max(mx, get_score(r-1, r, hl, hr)); dp[r][hr] = mx; res = max(res, dp[r][hr] + ps[r+1][hr]); } } 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...