Submission #1079629

#TimeUsernameProblemLanguageResultExecution timeMemory
1079629ArthuroWichCatfish Farm (IOI22_fish)C++17
52 / 100
926 ms2097152 KiB
#include "fish.h" #include<bits/stdc++.h> using namespace std; #define int long long int int pref[3005][3005]; int query(int j, int i1, int i2) { if (i1 > i2) { return 0; } return pref[i2][j]-pref[i1-1][j]; } 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(n+1, vector<int>(2, 0)), tdp(n+1, vector<int>(2, 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[i][0]-pref[i][j-1]); tdp[i][0] = max(v+pref[i][j-1], dp[0][1]); } v = 0; for (int i = n; i >= 0; i--) { v= max(v, max(dp[i][0], dp[i][1])+pref[i][j]); tdp[i][1] = v-pref[i][j]; } swap(dp, tdp); } int ans = max(dp[0][0], dp[0][1]); 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...