Submission #1079652

#TimeUsernameProblemLanguageResultExecution timeMemory
1079652ArthuroWichCatfish Farm (IOI22_fish)C++17
0 / 100
876 ms2097152 KiB
#include "fish.h" #include<bits/stdc++.h> using namespace std; #define int long long int int pref[3005][3005]; int max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) { int n = N, m = M; vector<vector<int>> c(n+1, vector<int>(n+1, 0)); vector<vector<int>> dp(2, vector<int>(n+1, 0)), tdp(2, vector<int>(n+1, 0)); // 0 is increasing, 1 is decreasing, increasing can go to decreasing, decreasing cant go to increasing if next to eachother for (int i = 0; i < m; i++) { c[Y[i]+1][X[i]] = W[i]; pref[Y[i]+1][X[i]] = W[i]; } for (int j = 0; j < n; j++) { for (int i = 1; i <= n; i++) { pref[i][j] += pref[i-1][j]; } } for (int j = 1; j <= n; j++) { int v = 0; for (int i = 0; i <= n; i++) { v = max(v, dp[0][i]-pref[i][j-1]); tdp[0][i] = max(v+pref[i][j-1], dp[0][1]); } v = 0; for (int i = n; i >= 0; i--) { v= max(v, max(dp[0][i], dp[1][i])+pref[i][j]); tdp[1][i] = v-pref[i][j]; } swap(dp, tdp); } int ans = max(dp[0][0], dp[1][0]); 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...