Submission #471026

#TimeUsernameProblemLanguageResultExecution timeMemory
471026iulia13Friend (IOI14_friend)C++14
100 / 100
36 ms3356 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; const int N = 1e5 + 5; int dp[N][2]; int c[N], h[N], p[N]; int findSample(int n, int confidence[], int host[], int protocol[]) { int i; for (i = 0; i < n; i++) dp[i][1] = confidence[i]; for (i = n - 1; i; i--) { int j = host[i]; if (protocol[i] == 0) { dp[j][0] += max(dp[i][0], dp[i][1]); dp[j][1] += dp[i][0]; continue; } int t = dp[i][0]; if (protocol[i] == 1) t = max(t, dp[i][1]); dp[j][1] += t; dp[j][1] = max(dp[j][1], dp[j][0] + dp[i][1]); dp[j][0] += dp[i][0]; } return max(dp[0][0], dp[0][1]); } /* int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> c[i]; for (int i = 1; i < n; i++) cin >> h[i] >> p[i]; cout << findSample(n, c, h, p); return 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...