Submission #282380

#TimeUsernameProblemLanguageResultExecution timeMemory
282380SamAndFriend (IOI14_friend)C++17
100 / 100
50 ms3576 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int N = 100005; int v[N], cv[N]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; ++i) { v[i] = confidence[i]; cv[i] = 0; } for (int i = n - 1; i > 0; --i) { if (protocol[i] == 0) { v[host[i]] = v[host[i]] + cv[i]; cv[host[i]] = max(cv[host[i]] + v[i], cv[host[i]] + cv[i]); } else if (protocol[i] == 2) { v[host[i]] = max(v[host[i]] + cv[i], cv[host[i]] + v[i]); cv[host[i]] = cv[host[i]] + cv[i]; } else { v[host[i]] = max(max(v[host[i]] + cv[i], cv[host[i]] + v[i]), v[host[i]] + v[i]); cv[host[i]] = cv[host[i]] + cv[i]; } } return max(v[0], cv[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...