제출 #1210793

#제출 시각아이디문제언어결과실행 시간메모리
1210793qwushaCatfish Farm (IOI22_fish)C++20
0 / 100
1097 ms13380 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define fi first #define se second typedef long long ll; typedef long double ld; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); ll inf = 1e18; ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { int K = min(n, 8); vector<vector<ll>> a(n, vector<ll>(K + 1)); for (int i = 0; i < m; i++) { a[x[i]][y[i]] = w[i]; } for (int i = 0; i < n; i++) { for (int j = 1; j < n; j++) { a[i][j] += a[i][j - 1]; } } vector<vector<ll>> dp(K + 1, vector<ll>(K + 1)), newdp(K + 1, vector<ll>(K + 1)); ll res = 0; for (int i = 0; i <= K; i++) { for (int j = 0; j <= K; j++) { ll val = 0; if (n > 2) { val = a[2][j]; } ll v1 = max(0ll, a[1][i] - a[1][j]); ll v0 = max(0ll, a[0][j] - a[0][i]); dp[i][j] = val + v0 + v1; res = max(res, dp[i][j]); } } newdp = dp; for (int beg = 1; beg < n - 1; beg++) { for (int i = 0; i <= K; i++) { for (int j = 0; j <= K; j++) { for (int k = 0; k <= K; k++) { ll val = 0; if (beg < n - 2) { val = a[beg + 2][j]; } ll nv = dp[k][i]; nv += val; nv -= a[beg + 1][min(j, i)]; nv += max(0ll, a[beg][j] - a[beg][max(i, k)]); newdp[i][j] = max(newdp[i][j], nv); } res = max(res, newdp[i][j]); } } dp = newdp; } return res; } /* signed main() { int n, m; cin >> n >> m; vector<int> x(m), y(m), w(m); for (int i = 0; i < m; i++) { cin >> x[i] >> y[i] >> w[i]; } cout << max_weights(n,m,x,y,w) << '\n'; }*/
#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...