Submission #642504

#TimeUsernameProblemLanguageResultExecution timeMemory
642504tigarCatfish Farm (IOI22_fish)C++17
18 / 100
83 ms7268 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { bool subtask1=true, subtask2=true, subtask3=true; for(int i=0; i<M; i++) { if(X[i]%2!=0)subtask1=false; if(X[i]>1)subtask2=false; if(Y[i]!=0)subtask3=false; } if(subtask1) { ll rez=0; for(int i=0; i<M; i++)rez+=W[i]; return rez; } if(subtask2) { ll s1=0, s0=0, m[N][2]={0}; for(int i=0; i<M; i++) { if(X[i]==0)s0+=W[i]; else s1+=W[i]; m[Y[i]][X[i]]=W[i]; } for(int i=1; i<N; i++) { m[i][0]=m[i-1][0]+m[i][0]; m[i][1]=m[i-1][1]+m[i][1]; } if(N==2)return max(m[N-1][0], m[N-1][1]); ll rez=s1; for(int i=0; i<N; i++) { rez=max(rez, m[i][0]+m[N-1][1]-m[i][1]); } return rez; } if(subtask3) { ll m[N]={0}; for(int i=0; i<M; i++) { m[X[i]]=W[i]; } ll dp[N][2]={0}; dp[0][1]=0; dp[0][0]=0; dp[1][1]=m[0]; dp[1][0]=m[1]; for(int i=2; i<N; i++) { dp[i][1]=max(dp[i-1][0], max(dp[i-2][0]+m[i-1], dp[i-1][1])); dp[i][0]=max(dp[i-1][1]+m[i], dp[i-1][0]); } return max(dp[N-1][0], dp[N-1][1]); } 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...