Submission #1073191

#TimeUsernameProblemLanguageResultExecution timeMemory
1073191ZicrusCatfish Farm (IOI22_fish)C++17
0 / 100
17 ms5860 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; int n, m; vector<int> x, y, w; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { n = N; m = M; x = X; y = Y; w = W; vector<ll> a(n); for (int i = 0; i < m; i++) { a[x[i]] = w[i]; } vector<ll> dp(n); dp[1] = w[0]; for (int i = 2; i < n; i++) { dp[i] = w[i-1]; for (int j = i-1; j >= 0 && j >= i-5; j--) { ll val = dp[j]; if (i-j > 1) val += w[i-1]; if (i-j > 2) val += w[j+1]; dp[i] = max(dp[i], val); } } ll res = dp[n-1]; for (int i = n-2; i >= n-5 && i >= 0; i--) { res = max(res, dp[i] + w[i+1]); } return res; } #ifdef TEST #include "grader.cpp" #endif
#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...