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;
#define ar array
// Find out best sample
int findSample(int n,int A[],int host[],int p[]){
ar<int, 2> ans[n];
for(int i = 0;i < n;i++)ans[i] = {A[i], 0};
for(int i = n- 1;i >= 1;i--){
int j = host[i];
if(p[i] == 0){
ans[j][0] += ans[i][1];
ans[j][0] = max(ans[j][0], ans[i][0] + ans[j][1]);
ans[j][1] += max(ans[i][0], ans[i][1]);
}
else if(p[i] == 1){
ans[j][0] += max(ans[i][0], ans[i][1]);
ans[j][1] += ans[i][1];
}else{
ans[j][0] += ans[i][1];
ans[j][0] = max(ans[j][0], ans[i][0] + ans[j][1]);
ans[j][1] += ans[i][1];
}
}
return max(ans[0][0], ans[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... |