제출 #425607

#제출 시각아이디문제언어결과실행 시간메모리
425607vanic친구 (IOI14_friend)C++14
100 / 100
35 ms3368 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...