제출 #1073241

#제출 시각아이디문제언어결과실행 시간메모리
1073241Zicrus메기 농장 (IOI22_fish)C++17
0 / 100
840 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)); vector<vector<ll>> dpNo(n, vector<ll>(n)); for (int i = 1; i < n; i++) { for (int j = 0; j < min(n, 10); j++) { for (int j1 = 0; j1 < min(n, 10); j1++) { // next to i ll val = dpNo[i-1][j1]; for (int k = j+1; k <= j1; k++) { val += a[i][k]; } for (int k = j1+1; k <= j; k++) { val += a[i-1][k]; } dp[i][j] = max(dp[i][j], val); } for (int i1 = i-2; i1 >= 0 && i1 >= i-5; i1--) { for (int j1 = 0; j1 < min(n, 10); j1++) { ll val = dp[i1][j1]; if (i1 == i-2) { for (int k = 0; k <= max(j, j1); k++) { val += a[i-1][k]; } } else { for (int k = 0; k <= j; k++) { val += a[i-1][k]; } for (int k = 0; k <= j1; k++) { val += a[i1+1][k]; } } dp[i][j] = max(dp[i][j], val); dpNo[i][j] = max(dpNo[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...