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 <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iostream>
using namespace std;
const int maxn=1e5+5;
int n;
pair < int, int > p[maxn];
int findSample(int n, int l[], int parent[], int koji[]){
for(int i=0; i<n; i++){
p[i].first=l[i];
}
int y;
for(int i=n-1; i>0; i--){
y=parent[i];
if(koji[i]==0){
p[y].first+=p[i].second;
p[y].second+=max(p[i].first, p[i].second);
}
else if(koji[i]==1){
p[y].first=max(p[i].first, p[i].second)+max(p[y].first, p[y].second);
p[y].second+=p[i].second;
}
else{
p[y].first=max(p[i].second+p[y].first, p[i].first+p[y].second);
p[y].second+=p[i].second;
}
}
return max(p[0].first, p[0].second);
}
# | 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... |