Submission #627256

#TimeUsernameProblemLanguageResultExecution timeMemory
627256coloboxxCatfish Farm (IOI22_fish)C++17
12 / 100
91 ms9676 KiB
#include "fish.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int MAXN = 300064; ll a[MAXN], dp[MAXN][2]; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { for (int i = 0; i < M; ++i) a[X[i] + 1] = W[i]; for (int i = 2; i <= N; ++i) { dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + a[i]); dp[i][1] = dp[i - 1][1]; if (i > 2) dp[i][1] = max({ dp[i][1], dp[i - 2][0] + a[i - 1], dp[i - 2][1] + a[i - 1] }); else dp[i][1] = max(dp[i][1], a[i - 1]); } ll ans = 0; for (int i = 1; i <= N; ++i) ans = max({ ans, dp[i][0], dp[i][1] }); return (*max_element(Y.begin(), Y.end()) ? accumulate(W.begin(), W.end(), 0ll) : 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...