Submission #1075480

#TimeUsernameProblemLanguageResultExecution timeMemory
1075480Muhammad_AneeqCatfish Farm (IOI22_fish)C++17
3 / 100
53 ms7268 KiB
#include <vector> using namespace std; long long max_weights(int N, int M, vector<int> X, vector<int> Y,vector<int> W) { bool subt1=1,subt2=1,subt3=1; for (int i=0;i<M;i++) { if (X[i]%2) subt1=0; if (X[i]>1) subt2=0; if (Y[i]!=0) subt3=0; } if (subt1) { long long sm=0; for (int i=0;i<M;i++) sm+=W[i]; return sm; } if (subt2) { long long sm[N]={}; vector<vector<long long>>val(2,vector<long long>(N,0)); for (int i=0;i<M;i++) val[X[i]][Y[i]]=W[i]; sm[0]=val[1][0]; for (int i=1;i<N;i++) sm[i+1]=sm[i]+val[1][i]; long long ans=sm[N-1]; long long x=0; for (int i=0;i<N;i++) { x+=val[0][i]; ans=max(ans,x+sm[N-1]-sm[i]); } return ans; } if (subt3) { long long dp[N][2]={}; int val[N]={}; for (int i=0;i<M;i++) val[X[i]]=W[i]; dp[0][0]=0,dp[0][1]=val[0]; long long ans=0; for (int i=1;i<N;i++) { if (i>1) dp[i][0]=max(dp[i-2][0],dp[i-2][1])+val[i]; else dp[i][0]=val[i]; if (i<N-1) dp[i][1]=max(dp[i][0],dp[i-1][0]+val[i]); ans=max(ans,max(dp[i][0],dp[i][1])); } return ans; } 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...