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 = n - 1; i > 0; i--)
{
int hs = host[i];
if (protocol[i] == 0)
{
take[hs] += nottake[i];
nottake[hs] += max(take[i], nottake[i]);
}
else if (protocol[i] == 1)
{
take[hs] = max(take[hs] + max(take[i], nottake[i]), nottake[hs] + take[i]);
nottake[hs] += nottake[i];
}
else
{
take[hs] = max(take[hs] + nottake[i], take[i] + nottake[hs]);
nottake[hs] += nottake[i];
}
}
return max(take[0], nottake[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... |