Submission #628243

#TimeUsernameProblemLanguageResultExecution timeMemory
628243c28dnv9q3Catfish Farm (IOI22_fish)C++17
9 / 100
30 ms12116 KiB
#include "fish.h" #include <vector> using namespace std; using ll = long long; const int N_MAX = 100005; ll v[N_MAX]; ll dp[N_MAX]; bool got[N_MAX]; ll f(int i) { if (i == 0) return 0; if (got[i]) return dp[i]; ll ans = f(i-1); if (i == 1) { ans = max(v[0], v[1]); } else if (i == 2) { ans = max(ans, v[0] + v[2]); } if (i >= 2) { ans = max(ans, v[i-1] + f(i-2)); } if (i >= 3) { ans = max(ans, f(i-3) + v[i] + v[i-2]); } if (i >= 4) { ans = max(ans, f(i-4) + v[i] + v[i-3]); } got[i] = true; return dp[i] = ans; } ll max_weights( int N, int M, vector<int> X, vector<int> Y, vector<int> W ) { for (int i = 0; i < M; i++) v[X[i]] = W[i]; return f(N-1); }
#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...