제출 #589595

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