Submission #276761

#TimeUsernameProblemLanguageResultExecution timeMemory
276761MKopchevFriend (IOI14_friend)C++14
100 / 100
40 ms3448 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; const int nmax=1e5+42; int with[nmax],without[nmax]; int findSample(int n,int confidence[],int host[],int protocol[]) { for(int i=0;i<n;i++)with[i]=confidence[i]; for(int i=n-1;i>0;i--) { if(protocol[i]==1) { with[host[i]]=max(max(with[host[i]]+with[i],with[host[i]]+without[i]),without[host[i]]+with[i]); without[host[i]]+=without[i]; } else if(protocol[i]==2) { with[host[i]]=max(with[host[i]]+without[i],with[i]+without[host[i]]); without[host[i]]+=without[i]; } else { with[host[i]]+=without[i]; without[host[i]]+=max(with[i],without[i]); } /* cout<<i<<":"<<endl; for(int j=0;j<=i;j++) { cout<<j<<" -> "<<with[j]<<" "<<without[j]<<endl; } */ } return max(with[0],without[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...