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 <vector>
#include <iostream>
#include <algorithm>
#define int int64_t
using namespace std;
// Find out best sample
signed findSample(signed n, signed confidence[], signed host[], signed protocol[])
{
vector<int> take;
for (int i = 0; i < n; i++) take.push_back(confidence[i]);
vector<int> nottake(n, 0);
for (int i = 1; i < n; i++)
{
int hs = host[i];
if (protocol[i] == 0)
{
take[i] += nottake[hs];
nottake[i] += max(take[hs], nottake[hs]);
}
else if (protocol[i] == 1)
{
take[i] = max(take[i] + max(take[hs], nottake[hs]), nottake[i] + take[hs]);
nottake[i] += nottake[hs];
}
else
{
take[i] = max(take[i] + nottake[hs], take[hs] + nottake[i]);
nottake[i] += nottake[hs];
}
}
return max(take[n - 1], nottake[n - 1]);
}
# | 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... |