제출 #544378

#제출 시각아이디문제언어결과실행 시간메모리
544378sliviu친구 (IOI14_friend)C++17
35 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]) { vector<pair<int, int>> dp(n); for (int i = 0; i < n; ++i) dp[i].first = confidence[i]; for (int i = n - 1; i; --i) { int cur = host[i], last = i; if (protocol[i] == 0) dp[cur] = {dp[cur].first + dp[last].second,dp[cur].second + max(dp[last].first,dp[last].second)}; else if (protocol[i] == 1) dp[cur] = {dp[cur].first + max(dp[last].first,dp[last].second),dp[cur].second + max(dp[last].first,dp[last].second)}; else dp[cur] = {max(dp[cur].first + dp[last].second,dp[cur].second + dp[last].first),dp[cur].second + dp[last].second}; } return max(dp[0].first, dp[0].second); }
#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...