Submission #589595

#TimeUsernameProblemLanguageResultExecution timeMemory
589595AlperenTFriend (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...