# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153364 | arnold518 | Friend (IOI14_friend) | C++14 | 39 ms | 3448 KiB |
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 "friend.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
pii dp[MAXN+10];
int findSample(int N, int *C, int *H, int *P)
{
int i, j;
for(i=0; i<N; i++) dp[i]={C[i], 0};
for(i=N-1; i>=1; i--)
{
if(P[i]==0) dp[H[i]]={dp[H[i]].first+dp[i].second, max(dp[i].first+dp[H[i]].second, dp[i].second+dp[H[i]].second)};
else if(P[i]==1) dp[H[i]]={max({dp[H[i]].first+dp[i].second, dp[i].first+dp[H[i]].second, dp[i].first+dp[H[i]].first}), dp[i].second+dp[H[i]].second};
else dp[H[i]]={max(dp[H[i]].first+dp[i].second, dp[i].first+dp[H[i]].second), dp[i].second+dp[H[i]].second};
}
return max(dp[0].first, dp[0].second);
}
Compilation message (stderr)
# | 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... |