This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include<algorithm>
using namespace std;
int iranov[200000],aranc_ira[200000];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=0;i<n;i++)
{
iranov[i]=confidence[i];
aranc_ira[i]=0;
}
for(int i=n-1;i>=1;i--)
{
if(protocol[i]==0)
{
iranov[host[i]]=iranov[host[i]]+aranc_ira[i];
aranc_ira[host[i]]=max(aranc_ira[i]+aranc_ira[host[i]],iranov[i]+aranc_ira[host[i]]);
}
if(protocol[i]==1)
{
iranov[host[i]]=max(max(iranov[host[i]]+iranov[i],iranov[host[i]]+aranc_ira[i]),aranc_ira[host[i]]+iranov[i]);
aranc_ira[host[i]]=aranc_ira[host[i]]+aranc_ira[i];
}
if(protocol[i]==2)
{
iranov[host[i]]=max(iranov[host[i]]+aranc_ira[i],iranov[i]+aranc_ira[host[i]]);
aranc_ira[host[i]]=aranc_ira[host[i]]+aranc_ira[i];
}
}
return max(aranc_ira[host[1]],iranov[host[1]]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |