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>
int d1[100000];
int d2[100000];
int findSample(int n,int c[],int h[],int p[])
{
int i;
for(i=0;i<n;i++)d1[i]=c[i];
for(i=n-1;i>0;i--)
{
if(p[i]==0)
{
d1[h[i]]+=d2[i];
d2[h[i]]+=std::max(d1[i],d2[i]);
}
if(p[i]==1)
{
d1[h[i]]=std::max(d2[h[i]]+d1[i],d1[h[i]]+std::max(d1[i],d2[i]));
d2[h[i]]+=d2[i];
}
if(p[i]==2)
{
d1[h[i]]=std::max(d2[h[i]]+d1[i],d1[h[i]]+d2[i]);
d2[h[i]]+=d2[i];
}
}
return std::max(d1[0],d2[0]);
}
# | 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... |