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<bits/stdc++.h>
using namespace std;
const int nmax=1e5+42;
int with[nmax],without[nmax];
int findSample(int n,int confidence[],int host[],int protocol[])
{
for(int i=0;i<n;i++)with[i]=confidence[i];
for(int i=n-1;i>0;i--)
{
if(protocol[i]==1)
{
with[host[i]]=max(max(with[host[i]]+with[i],with[host[i]]+without[i]),without[host[i]]+with[i]);
without[host[i]]+=without[i];
}
else if(protocol[i]==2)
{
with[host[i]]=max(with[host[i]]+without[i],with[i]+without[host[i]]);
without[host[i]]+=without[i];
}
else
{
with[host[i]]+=without[i];
without[host[i]]+=max(with[i],without[i]);
}
/*
cout<<i<<":"<<endl;
for(int j=0;j<=i;j++)
{
cout<<j<<" -> "<<with[j]<<" "<<without[j]<<endl;
}
*/
}
return max(with[0],without[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... |