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"
int D[100000][2];
int MAX(int X, int Y)
{
if(X>Y)
return X;
return Y;
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
int i;
for(i=0 ; i<n ; i++)
D[i][0]=confidence[i];
for(i=n-1 ; i>=1 ; i--)
{
if(protocol[i]==0)
{
D[host[i]][0]+=D[i][1];
D[host[i]][1]+=MAX(D[i][0],D[i][1]);
}
else if(protocol[i]==1)
{
D[host[i]][0]=MAX(D[host[i]][0]+MAX(D[i][0],D[i][1]),D[host[i]][1]+D[i][0]);
D[host[i]][1]+=D[i][1];
}
else
{
D[host[i]][0]=MAX(D[host[i]][0]+D[i][1],D[host[i]][1]+D[i][0]);
D[host[i]][1]+=D[i][1];
}
}
return MAX(D[0][0],D[0][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... |