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 <bits/stdc++.h>
using namespace std;
#define MAXN 100005
static int D[MAXN], E[MAXN];
int findSample(int n, int c[], int h[], int p[])
{
for (int i=0;i<n;i++) D[i] = c[i];
for (int i=n;--i;){
int t = h[i];
if (p[i] == 0){
D[t] += E[i];
E[t] = max(E[t] + D[i], E[t] + E[t]);
}else if (p[i] == 1){
D[t] = max(D[t] + D[i], max(D[t] + E[i], E[t] + D[i]));
E[t] += E[i];
}else{
D[t] = max(D[t] + E[i], E[t] + D[i]);
E[t] += E[i];
}
}
return max(D[0], E[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... |