Submission #836813

#TimeUsernameProblemLanguageResultExecution timeMemory
836813SupersonicCatfish Farm (IOI22_fish)C++17
18 / 100
73 ms12864 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) { bool s1=1,s2=1,s3=1; for(auto i:x){if(i%2==1)s1=0;if(i>=2)s2=0;} for(auto i:y)if(i>0)s3=0; if(s1){ long long t=0; for(auto i:w)t+=i; return t; } vector<pair<int,int>> a[n]; int sa0[n];int sa1[n]; for(int i=0;i<n;i++)sa0[i]=sa1[i]=0; for(int i=0;i<m;i++){ a[x[i]].push_back({y[i],w[i]}); if(x[i]==0)sa0[y[i]]=w[i]; if(x[i]==1)sa1[y[i]]=w[i]; } if(s2){ if(n==2){ long long at=0,bt=0; for(auto i:a[0])at+=i.second; for(auto i:a[1])bt+=i.second; return max(at,bt); } long long t=0; for(auto i:a[1])t+=i.second; long long ai=0,bi=t; for(int i=0;i<n;i++){ ai+=sa0[i];bi-=sa1[i]; t=max(t,ai+bi); } return t; } if(s3){ ll aa[n]; for(int i=0;i<n;i++)aa[i]=0; for(int i=0;i<m;i++){aa[x[i]]=w[i];} ll dp[n][2]; dp[0][0]=0;dp[0][1]=0; dp[1][0]=aa[1];dp[1][1]=aa[0]; for(int i=2;i<n;i++){dp[i][0]=max(dp[i-1][0],dp[i-1][1]+aa[i]);dp[i][1]=max({dp[i-1][1],dp[i-1][0],dp[i-2][0]+aa[i-1]});} return max(dp[n-1][0],dp[n-1][1]); } return 0; } /* 5 4 0 0 5 1 0 2 4 0 1 3 0 3 */
#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...