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 <bits/stdc++.h>
using namespace std;
int findSample(int n, int w[], int h[], int typ[]){
int c[n], u[n];
for (int i = 0; i < n; i++) c[i] = w[i], u[i] = 0;
for (int i = n - 1; i >= 1; i--) {
int x = h[i], y = i;
if (typ[i] == 0) {
c[x] += u[y];
u[x] = max(c[y] + u[x], u[x] + u[y]);
} else if (typ[i] == 1) {
c[x] = max({c[x] + c[y], u[x] + c[y], u[y] + c[x]});
u[x] += u[y];
} else {
c[x] = max(u[x] + c[y], u[y] + c[x]);
u[x] += u[y];
}
}
return max(c[0], u[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... |