Submission #1044998

#TimeUsernameProblemLanguageResultExecution timeMemory
1044998enderCatfish Farm (IOI22_fish)C++17
0 / 100
14 ms5464 KiB
#include "fish.h" #include <bits/stdc++.h> #include <vector> using namespace std; const long long INF = 1e18; const int MAXN = 1e5; int n; long long memo[MAXN]; bool cached[MAXN]; int a[MAXN]; long long dp(int i, bool check){ if(i >= n-1) return 0; if(cached[i]) return memo[i]; long long res = -INF; if(check){ long long act1 = dp(i+2, true) + a[i+1]; long long act2 = dp(i+1, false); res = max({res, act1, act2}); } else { long long act1 = dp(i+2, true) + a[i+1] + a[i-1]; long long act2 = dp(i+1, false); res = max({res, act1, act2}); } memo[i] = res; cached[i] = true; return res; } long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { n = N; for(int i = 0; i < n; ++i) a[i] = 0; for(int i = 0; i<M; ++i){ a[X[i]] = W[i]; } return dp(0, true); }
#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...