Submission #857242

#TimeUsernameProblemLanguageResultExecution timeMemory
857242ntkphongFriend (IOI14_friend)C++14
100 / 100
20 ms2908 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int MAXSIZE = 1e5 + 10; int findSample(int n, int confidence[], int host[], int protocol[]) { vector<int> p(n, 0); vector<int> q(n, 0); for(int i = 0; i < n; i ++) q[i] = confidence[i]; for(int i = n - 1; i > 0; i --) { int j = host[i]; if(protocol[i] == 0) { p[j] = max(p[j] + p[i], p[j] + q[i]); q[j] = q[j] + p[i]; } if(protocol[i] == 1) { q[j] = max({q[j] + p[i], q[j] + q[i], p[j] + q[i]}); p[j] = p[j] + p[i]; } if(protocol[i] == 2) { q[j] = max(q[j] + p[i], p[j] + q[i]); p[j] = p[j] + p[i]; } } return max(p[0], q[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...