제출 #1020259

#제출 시각아이디문제언어결과실행 시간메모리
1020259amirhoseinfar1385친구 (IOI14_friend)C++17
35 / 100
1 ms604 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]; } 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); 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...