Submission #104242

#TimeUsernameProblemLanguageResultExecution timeMemory
104242alexpetrescuFriend (IOI14_friend)C++14
100 / 100
62 ms8184 KiB
#include "friend.h" #include <algorithm> #include <vector> // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ std::vector < std::vector < int > > d(n, std::vector < int > (2, 0)); for (int i = 0; i < n; i++) d[i][1] = confidence[i]; for (int i = n - 1; i > 0; i--) { int x = host[i]; if (protocol[i] == 0) { d[x][0] += std::max(d[i][1], d[i][0]); d[x][1] += d[i][0]; } else if (protocol[i] == 1) { d[x][1] = std::max(std::max(d[x][1] + d[i][1], d[x][1] + d[i][0]), d[x][0] + d[i][1]); d[x][0] += d[i][0]; } else { d[x][1] = std::max(d[x][0] + d[i][1], d[x][1] + d[i][0]); d[x][0] += d[i][0]; } } return std::max(d[0][1], d[0][0]); }
#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...