Submission #1073193

#TimeUsernameProblemLanguageResultExecution timeMemory
1073193ZicrusCatfish Farm (IOI22_fish)C++17
9 / 100
23 ms7004 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] = a[0]; for (int i = 2; i < n; i++) { dp[i] = a[i-1]; for (int j = i-1; j >= 0 && j >= i-5; j--) { ll val = dp[j]; if (i-j > 1) val += a[i-1]; if (i-j > 2) val += a[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] + a[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...