Submission #73888

#TimeUsernameProblemLanguageResultExecution timeMemory
73888funcsrFriend (IOI14_friend)C++17
35 / 100
5 ms720 KiB
#include "friend.h" #include <iostream> #include <vector> #include <cassert> #include <tuple> #include <queue> #define rep(i, n) for (int i=0; i<(n); i++) #define pb push_back using namespace std; int dp0[100000], dp1[100000]; int findSample(int N, int A[], int host[], int protocol[]) { rep(i, N) dp0[i] = 0, dp1[i] = A[i]; for (int x=N-1; x>0; x--) { int p = host[x]; if (protocol[x] == 0) { dp0[p] += max(dp0[x], dp1[x]); dp1[p] += dp0[x]; } else if (protocol[x] == 1) { dp0[p] += dp0[x]; dp1[p] += max(dp0[x], dp1[x]); } else { dp0[p] += dp0[x]; dp1[p] = max(max(dp0[x]+dp1[p], dp1[x]+dp0[p]), dp0[x]+dp0[p]); } } 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...