This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |