Submission #1130664

#TimeUsernameProblemLanguageResultExecution timeMemory
1130664vibeduckCatfish Farm (IOI22_fish)C++20
0 / 100
42 ms9796 KiB
#include "fish.h" #include <vector> #include <bits/stdc++.h> using namespace std; //#define int long long long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { // y[i] = 0 vector<vector<long long>> dp(N, vector<long long>(3)); vector<long long> a(N, 0); for (int i = 0; i < M; i++) a[X[i]] = W[i]; dp[0][0] = dp[1][0] = 0; dp[0][1] = a[0]; dp[1][1] = a[1]; dp[1][2] = a[0] + a[1]; for (int i = 2; i < N; i++) { dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]}); dp[i][1] = max({dp[i - 1][0] + a[i], dp[i - 1][1] - a[i - 1] + a[i], dp[i - 1][2] - a[i - 1] + a[i]}); dp[i][2] = max({dp[i - 1][1] + a[i]}); } long long ans = 0; for (int i = 0; i < N; i++) ans = max(ans, max({dp[i][0], dp[i][1], dp[i][2]})); return 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...