이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |