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 <algorithm>
using namespace std;
#define f first
#define s second
pair<int, int> dp[100001];
int findSample(int n, int confidence[], int host[], int protocol[]) {
for (int i=0; i<n; i++) dp[i] = {confidence[i], 0};
for (int i=n-1; i>0; i--) {
int j = host[i], type = protocol[i];
if (type == 0) dp[j] = {dp[j].f+dp[i].s, dp[j].s+max(dp[i].f, dp[i].s)};
else if (type == 1) dp[j] = {max(dp[j].f+max(dp[i].f, dp[i].s), dp[i].f+dp[j].s), dp[i].s+dp[j].s};
else dp[j] = {max(dp[j].f+dp[i].s, dp[i].f+dp[j].s), dp[i].s+dp[j].s};
}
return max(dp[0].f, dp[0].s);
}
# | 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... |