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;
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<int> do_not_use(n, 0);
vector<int> do_use(n, 0);
for (int i=0; i<n; i++)
do_use[i] = confidence[i];
for (int i=n-1; i>=1; i--)
{
int h = host[i];
int p = protocol[i];
if (p == 1)
{
do_not_use[h] = do_not_use[h]+do_not_use[i];
do_use[h] = do_use[h]+do_use[i];
}
else if (p==2)
{
do_not_use[h] = max(do_not_use[h], do_not_use[i]);
do_use[h] = max(do_use[h], do_use[i]);
}
else
{
do_not_use[h] = do_not_use[h] + do_use[i];
do_use[h] = do_use[h] + do_not_use[i];
if (do_use[h]<do_not_use[h])
do_use[h] = 0;
}
}
return max(do_not_use[0], do_use[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... |