Submission #1020264

#TimeUsernameProblemLanguageResultExecution timeMemory
1020264amirhoseinfar1385Friend (IOI14_friend)C++17
100 / 100
28 ms4184 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; const int maxn=100000+10; pair<long long,long long>dp[maxn]; int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=0;i<n;i++){ dp[i].first=confidence[i]; dp[i].second=0; } for(int i=n-1;i>0;i--){ // cout<<i<<" "<<host[i]<<" "<<protocol[i]<<endl; int p=host[i]; if(protocol[i]==0){ dp[p].first+=dp[i].second; dp[p].second+=max(dp[i].first,dp[i].second); }else if(protocol[i]==1){ dp[p].first=max(dp[i].first,dp[i].second)+max(dp[p].first,dp[p].second); dp[p].second+=dp[i].second; }else{ dp[p].first=max(dp[p].first+dp[i].second,dp[i].first+dp[p].second); dp[p].second+=dp[i].second; } } return max(dp[0].first,dp[0].second); }
#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...