제출 #1123294

#제출 시각아이디문제언어결과실행 시간메모리
1123294sunboi메기 농장 (IOI22_fish)C++20
0 / 100
1175 ms1736088 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { /*vector<pair<int, int>> a(M); for (int i = 0; i < M; i++){ a[i] = {X[i], Y[i]}; }*/ vector<vector<int>> pref(N, vector<int> (N + 1)); for (int i = 0; i < M; i++){ pref[X[i]][Y[i]] += W[i]; } for (int i = 0; i < N; i++){ for (int j = 1; j <= N; j++){ pref[i][j] += pref[i][j - 1]; } } vector<vector<int>> dp(N, vector<int> (N + 1)); int ans = 0; for (int i = 1; i < N; i++){ for (int prev = 0; prev <= N; prev++){ for (int j = 0; j <= N; j++){ int cogemos = 0; if (prev > j){ cogemos = pref[i][prev] - pref[i][j]; }else{ cogemos = pref[i - 1][j] - pref[i][prev]; } dp[i][j] = max(dp[i][j], dp[i - 1][prev] + cogemos); } } } for (int i = 0; i <= N; i++) ans = max(ans, dp[N - 1][i]); 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...