제출 #31166

#제출 시각아이디문제언어결과실행 시간메모리
31166pasa3232친구 (IOI14_friend)C++14
100 / 100
39 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=1; i<n; i++)A[i]=host[i],B[i]=protocol[i]; for(int i=n-1;i>0;i--){ int pj=p[A[i]], qj=q[A[i]], pi=p[i], qi=q[i]; 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...