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<algorithm>
using namespace std;
static int d[100005][2];
int findSample(int n, int c[], int t[], int pr[]){
int i, x;
for(i = 0; i < n; i++){
d[i][1] = c[i];
}
for(i = n - 1; i >= 1; i--){
x = t[i];
if(pr[i] == 0){
d[x][1] += d[i][0];
d[x][0] += d[i][1];
}
if(pr[i] == 1){
d[x][1] += d[i][1];
d[x][0] += d[i][0];
}
if(pr[i] == 2){
d[x][0] += d[i][0];
d[x][1] = max(d[i][0] + d[x][1], d[i][1] + d[x][0]);
}
d[x][1] = max(d[x][1], d[x][0]);
}
return d[0][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... |