제출 #1231801

#제출 시각아이디문제언어결과실행 시간메모리
1231801loloka메기 농장 (IOI22_fish)C++20
9 / 100
48 ms7240 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 f1 = 1, f2 = 1, f3 = 1; for(int i = 0; i < M; i++) { f1 &= (X[i] % 2 == 0); f2 &= (X[i] <= 1); f3 &= (Y[i] == 0); } if(f1) { long long ans = 0; for(int i = 0; i < M; i++) ans += W[i]; return ans; } if(f2) { long long pr[2][N + 1]; for(int i = 0; i < N + 1; i++) pr[0][i] = pr[1][i] = 0; for(int i = 0; i < M; i++) pr[X[i] % 2][Y[i] + 1] = W[i]; for(int i = 1; i <= N; i++) pr[0][i] += pr[0][i - 1], pr[1][i] += pr[1][i - 1]; long long ans = 0; for(int i = 1; i <= N; i++) ans = max(ans, pr[0][i - 1] + pr[1][N] - pr[1][i - 1]); if(N == 2) return max(pr[0][N], pr[1][N]); return ans; } if(f3) { long long dp[2][2][N + 1], mp[N + 1]; for(int i = 0; i < N + 1; i++) dp[0][0][i] = dp[0][1][i] = dp[1][0][i] = dp[1][1][i] = mp[i] = 0; for(int i = 0; i < M; i++) mp[X[i] + 1] = W[i]; dp[0][1][2] = mp[1]; dp[1][0][2] = mp[2]; for(int i = 3; i <= N; i++) { for(int j1 = 0; j1 < 2; j1++) { for(int j2 = 0; j2 < 2; j2++) { for(int j3 = 0; j3 < 2; j3++) { long long x = dp[j1][j2][i - 1]; if(j1 == 0 && j2 == 0 && j3 == 1) x += mp[i - 1]; if(j1 == 0 && j2 == 1 && j3 == 0) x += mp[i]; dp[j2][j3][i] = max(dp[j2][j3][i], x); } } } } return max({dp[0][0][N], dp[0][1][N], dp[1][0][N], dp[1][1][N]}); } return 0; }
#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...