Submission #416837

#TimeUsernameProblemLanguageResultExecution timeMemory
416837mjhmjh1104Friend (IOI14_friend)C++17
100 / 100
34 ms3024 KiB
#include "friend.h" #include <algorithm> using namespace std; int res[100006][2]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; i++) res[i][1] = confidence[i], res[i][0] = 0; for (int i = n - 1; i > 0; i--) { if (protocol[i] == 0) { res[host[i]][1] = res[i][0] + res[host[i]][1]; res[host[i]][0] = max(res[i][0], res[i][1]) + res[host[i]][0]; } else if (protocol[i] == 1) { res[host[i]][1] = max(res[i][1], res[i][0]) + max(res[host[i]][1], res[host[i]][0]); res[host[i]][0] = res[i][0] + res[host[i]][0]; } else { res[host[i]][1] = max(res[host[i]][1] + res[i][0], res[host[i]][0] + res[i][1]); res[host[i]][0] = res[host[i]][0] + res[i][0]; } } return max(res[0][0], res[0][1]); }
#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...