Submission #1124304

#TimeUsernameProblemLanguageResultExecution timeMemory
1124304allin27xFriend (IOI14_friend)C++20
100 / 100
23 ms2120 KiB
#include <bits/stdc++.h> using namespace std; #include "friend.h" int findSample(int n, int c[],int h[],int t[]){ vector<array<int,2>> dp(n); for (int i=0; i<n; i++) dp[i][0] = 0, dp[i][1] = c[i]; for (int i=n-1; i>0; i--) { int p = h[i]; if (t[i] == 0) { dp[p][0] = dp[p][0] + max(dp[i][0], dp[i][1]); dp[p][1] = dp[p][1] + dp[i][0]; } if (t[i] == 1) { dp[p][1] = max(max(dp[p][1] + dp[i][0], dp[p][0] + dp[i][1]), dp[p][1] + dp[i][1]); dp[p][0] = dp[p][0] + dp[i][0]; } if (t[i] == 2) { dp[p][1] = max(dp[p][1] + dp[i][0], dp[p][0] + dp[i][1]); dp[p][0] = dp[p][0] + dp[i][0]; } } return max(dp[0][0], dp[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...