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];
int dnuh = do_not_use[h];
int duh = do_use[h];
if (p == 1)
{
do_not_use[h] = dnuh+do_not_use[i];
do_use[h] = duh+do_use[i];
}
else if (p == 2)
{
do_not_use[h] = dnuh + do_not_use[i];
do_use[h] = max(dnuh + do_use[i], duh + do_not_use[i]);
}
else
{
do_not_use[h] = dnuh + do_use[i];
do_use[h] = duh + do_not_use[i];
do_use[h] = max(do_use[h], do_not_use[h]);
}
}
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... |