Submission #70890

#TimeUsernameProblemLanguageResultExecution timeMemory
70890aquablitz11Friend (IOI14_friend)C++14
100 / 100
48 ms6840 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; const int N = 1e5+10; int P[N], NP[N]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; ++i) P[i] = confidence[i], NP[i] = 0; for (int i = n-1; i > 0; --i) { int &u = P[host[i]]; int &up = NP[host[i]]; int &v = P[i]; int &vp = NP[i]; int nu, nup; if (protocol[i] == 0) { nu = u+vp; nup = up+max(v,vp); } else if (protocol[i] == 1) { nu = max(u+v, max(up+v, u+vp)); nup = up+vp; } else { nu = max(u+vp, up+v); nup = up+vp; } u = nu, up = nup; } return max(P[0], NP[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...