Submission #1124299

#TimeUsernameProblemLanguageResultExecution timeMemory
1124299allin27xFriend (IOI14_friend)C++20
35 / 100
24 ms3140 KiB
#include <bits/stdc++.h> using namespace std; #include "friend.h" #define int long long signed findSample(signed n, signed c[],signed h[],signed 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][0] = dp[p][0] + dp[i][0]; dp[p][1] = max(max(dp[p][1] + dp[i][0], dp[p][0] + dp[i][1]), dp[p][1] + dp[i][1]); } if (t[i] == 2) { dp[p][0] = dp[p][0] + dp[i][0]; dp[p][1] = max(dp[p][1] + dp[i][0], dp[p][0] + dp[i][1]); } } 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...