Submission #231885

#TimeUsernameProblemLanguageResultExecution timeMemory
231885AlexLuchianovFriend (IOI14_friend)C++14
100 / 100
37 ms3448 KiB
#include "friend.h" #include <iostream> using namespace std; // Find out best sample int const nmax = 100000; pair<int, int> dp[1 + nmax]; int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i = 0; i < n; i++) dp[i] = {0, confidence[i]}; for(int i = n - 1;0 < i; i--){ int par = host[i]; if(protocol[i] == 0) dp[par] = {dp[par].first + dp[i].second, dp[par].second + dp[i].first}; else if(protocol[i] == 1) dp[par] = {dp[par].first + dp[i].first, dp[par].second + dp[i].second}; else if(protocol[i] == 2) dp[par] = {dp[par].first + dp[i].first, max(dp[par].first + dp[i].second, dp[par].second + dp[i].first)}; dp[par].second = max(dp[par].first, dp[par].second); } return dp[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...