Submission #61065

#TimeUsernameProblemLanguageResultExecution timeMemory
61065hamzqq9Friend (IOI14_friend)C++14
100 / 100
48 ms7052 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; #define st first #define nd second #define sz(x) (x.size()) #define pb push_back #define N 100005 int findSample(int n,int confidence[],int host[],int protocol[]) { int P[N],Q[N]={0}; for(int i=0;i<n;i++) P[i]=confidence[i]; for(int i=n-1;i>=1;i--) { int x=host[i]; int y=i; if(protocol[i]==0) { Q[x]=max(Q[x]+Q[y],P[y]+Q[x]); P[x]=P[x]+Q[y]; } if(protocol[i]==1) { P[x]=max(max(P[x]+Q[y],P[y]+Q[x]),P[x]+P[y]); Q[x]=Q[y]+Q[x]; } if(protocol[i]==2) { P[x]=max(P[y]+Q[x],P[x]+Q[y]); Q[x]=Q[x]+Q[y]; } } return max(P[0],Q[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...