Submission #81335

#TimeUsernameProblemLanguageResultExecution timeMemory
81335farukkastamonudaFriend (IOI14_friend)C++14
100 / 100
38 ms7576 KiB
#include "friend.h" #include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000000 #define md 1000000007 #define li 100005 #define mp make_pair #define pb push_back #define pi pair<lo int, int> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int P[li], Q[li] = {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],Q[x]+P[y]); P[x]=P[x]+Q[y]; } if(protocol[i]==1){ P[x]=max(P[x]+P[y],max(Q[x]+P[y],Q[y]+P[x])); Q[x]=Q[x]+Q[y]; } if(protocol[i]==2){ P[x]=max(P[x]+Q[y],Q[x]+P[y]); Q[x]=Q[x]+Q[y]; } } 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...