Submission #31165

#TimeUsernameProblemLanguageResultExecution timeMemory
31165pasa3232Friend (IOI14_friend)C++14
8 / 100
0 ms4752 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; int a,p[100010],q[100010],A[100010],B[100010]; int findSample(int n, int confidence[], int host[], int protocol[]){ for(int i=0; i<n; i++)p[i]=confidence[i]; for(int i=0; i<n-1; i++)A[i]=host[i],B[i]=protocol[i]; for(int i=n-2;i>=0;i--){ int pj=p[A[i]], qj=q[A[i]], pi=p[i+1], qi=q[i+1]; if(B[i]==0){ p[A[i]]=pj+qi; q[A[i]]=qj+max(pi, qi); } else if(B[i]==1){ p[A[i]]=max(pi+pj, max(pi+qj, qi+pj)); q[A[i]]=qi+qj; } else{ p[A[i]]=max(pj+qi, pi+qj); q[A[i]]=qi+qj; } } return max(q[0], p[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...