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 <iostream>
using namespace std;
// Find out best sample
int const nmax = 100000;
pair<int, int> dp[1 + nmax];
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i = 0; i < n; i++)
dp[i] = {0, confidence[i]};
for(int i = n - 1;0 < i; i--){
int par = host[i];
if(protocol[i] == 0)
dp[par] = {dp[par].first + dp[i].second, dp[par].second + dp[i].first};
else if(protocol[i] == 1)
dp[par] = {dp[par].first + dp[i].first, dp[par].second + dp[i].second};
else if(protocol[i] == 2)
dp[par] = {dp[par].first + dp[i].first, max(dp[par].first + dp[i].second, dp[par].second + dp[i].first)};
dp[par].second = max(dp[par].first, dp[par].second);
}
return dp[0].second;
}
# | 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... |