Submission #298748

#TimeUsernameProblemLanguageResultExecution timeMemory
298748juckterFriend (IOI14_friend)C++14
100 / 100
38 ms3448 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; // Find out best sample int findSample(int n, int confidence[], int host[], int protocol[]) { vector<int> dp0(n), dp1(n); for(int i = 0; i < n; i++) dp1[i] = confidence[i]; for(int v = n - 1; v >= 1; v--) { int u = host[v]; if(protocol[v] == 0) { dp1[u] = dp1[u] + dp0[v]; dp0[u] = dp0[u] + max(dp0[v], dp1[v]); } if(protocol[v] == 1) { dp1[u] = max({dp1[u] + dp1[v], dp1[u] + dp0[v], dp0[u] + dp1[v]}); dp0[u] += dp0[v]; } if(protocol[v] == 2) { dp1[u] = max(dp1[u] + dp0[v], dp0[u] + dp1[v]); dp0[u] += dp0[v]; } } return max(dp0[0], dp1[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...