Submission #652471

#TimeUsernameProblemLanguageResultExecution timeMemory
652471BlagojCatfish Farm (IOI22_fish)C++17
9 / 100
94 ms8048 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { bool Even = true, Less = true; for (auto x : X) { if (x % 2 != 0) { Even = false; } if (x > 1) { Less = false; } } if (Even) { long long sum = 0; for (auto x : W) { sum += x; } return sum; } if (Less) { long long m[N + 3][3]; memset(m, 0, sizeof(m)); for (int i = 0; i < M; i++) { m[Y[i]][X[i]] = W[i]; } for (int i = 1; i < N; i++) { m[i][0] += m[i - 1][0]; m[i][1] += m[i - 1][1]; } long long ans = max(m[N - 1][0], m[N - 1][1]); if (N == 2) { return ans; } for (int i = 0; i < N; i++) { ans = max(ans, m[i][0] + m[N - 1][1] - m[i][1]); } return ans; } long long dp[N + 3], p[N + 3]; memset(dp, 0, sizeof(dp)); memset(p, 0, sizeof(p)); for (int i = 0; i < M; i++) { p[X[i]] = W[i]; } dp[0] = p[0]; dp[1] = max(p[0], p[1]); dp[2] = max(dp[0] + p[2], dp[1]); for (int i = 3; i < N; i++) { dp[i] = max({dp[i - 3] + p[i - 1],dp[i - 2] + p[i], dp[i - 1]}); } return dp[N - 1]; }
#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...