Submission #93844

#TimeUsernameProblemLanguageResultExecution timeMemory
93844Bodo171Friend (IOI14_friend)C++14
100 / 100
33 ms3192 KiB
#include "friend.h" #include <iostream> using namespace std; const int nmax=100005; int best[nmax][2]; int a[nmax],val[nmax]; int nr,p,tip,i,tt; int findSample(int n,int confidence[],int host[],int protocol[]){ for(i=0;i<n;i++) best[i][1]=confidence[i]; for(int i=n-1;i>=1;i--) { tt=host[i];tip=protocol[i]; if(tip==0) { best[tt][0]+=max(best[i][0],best[i][1]); best[tt][1]+=best[i][0]; } if(tip==1) { best[tt][1]=max(max(best[tt][0]+best[i][1],best[tt][1]+best[i][0]),best[tt][1]+best[i][1]); best[tt][0]+=best[i][0]; } if(tip==2) { best[tt][1]=max(best[tt][0]+best[i][1],best[tt][1]+best[i][0]); best[tt][0]+=best[i][0]; } } return max(best[0][0],best[0][1]); }
#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...