Submission #742143

#TimeUsernameProblemLanguageResultExecution timeMemory
742143angelsFriend (IOI14_friend)C++14
100 / 100
28 ms3376 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 100005 static int D[MAXN], E[MAXN]; int findSample(int n, int c[], int h[], int p[]) { for (int i=0;i<n;i++) D[i] = c[i]; for (int i=n;--i;){ int t = h[i]; if (p[i] == 0){ D[t] += E[i]; E[t] = max(E[t] + D[i], E[t] + E[i]); }else if (p[i] == 1){ D[t] = max(D[t] + D[i], max(D[t] + E[i], E[t] + D[i])); E[t] += E[i]; }else{ D[t] = max(D[t] + E[i], E[t] + D[i]); E[t] += E[i]; } } return max(D[0], E[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...