Submission #681789

#TimeUsernameProblemLanguageResultExecution timeMemory
681789Jarif_RahmanCatfish Farm (IOI22_fish)C++17
0 / 100
1181 ms2097152 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W){ vector<vector<ll>> v(n, vector<ll>(n+1, 0)); for(int i = 0; i < n; i++) v[X[i]][Y[i]+1]+=W[i]; vector<vector<ll>> dp_up(n, vector<ll>(n+1, 0)), dp_down = dp_up; for(int i = n-1; i >= 0; i--) for(int j = 0; j <= n; j++){ if(i == n-1){ dp_down[i][j] = 0; dp_up[i][j] = 0; continue; } ll s = 0; for(int k = j; k <= n; k++){ if(k > j) s+=v[i][k]; dp_up[i][j] = max(dp_up[i][j], s+dp_up[i+1][k]); } s = 0; for(int k = j; k >= 0; k--){ if(k < j) s+=v[i+1][k]; dp_down[i][j] = max(dp_down[i][j], s+dp_down[i+1][k]); } s = 0; for(int k = j+1; k <= n; k++) s+=v[i][k]; dp_up[i][j] = max(dp_up[i][j], s+dp_down[i+1][n]); dp_down[i][j] = max(dp_down[i][j], dp_up[i+1][j]); } return max(*max_element(dp_up[0].begin(), dp_up[0].end()), *max_element(dp_down[0].begin(), dp_down[0].end())); }
#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...