제출 #293858

#제출 시각아이디문제언어결과실행 시간메모리
293858VodkaInTheJar친구 (IOI14_friend)C++14
100 / 100
36 ms3228 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; const int maxn = 1e5 + 3; pair <int, int> ans[maxn]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; i++) ans[i] = {confidence[i], 0}; for (int i = n-1; i >= 1; i--) { int par = host[i]; if (protocol[i] == 0) { ans[par].first += ans[i].second; ans[par].second += max(ans[i].first, ans[i].second); } else if (protocol[i] == 2) { ans[par].first = max(ans[par].first + ans[i].second, ans[par].second + ans[i].first); ans[par].second = ans[par].second + ans[i].second; } else { ans[par].first = max({ans[par].first + ans[i].first, ans[par].first + ans[i].second, ans[par].second + ans[i].first}); ans[par].second = ans[par].second + ans[i].second; } } return max(ans[0].first, ans[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...