제출 #693329

#제출 시각아이디문제언어결과실행 시간메모리
693329stevancv친구 (IOI14_friend)C++14
100 / 100
23 ms3444 KiB
#include <bits/stdc++.h> #include "friend.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const ll linf = 1e18; int dp[N][2]; int findSample(int n, int a[], int p[], int t[]) { for (int i = 0; i < n; i++) dp[i][0] = a[i]; for (int i = n - 1; i >= 1; i--) { if (t[i] == 0) { dp[p[i]][0] += dp[i][1]; dp[p[i]][1] += max(dp[i][0], dp[i][1]); } if (t[i] == 1) { dp[p[i]][0] = max({dp[p[i]][0] + dp[i][1], dp[p[i]][1] + dp[i][0], dp[p[i]][0] + dp[i][0]}); dp[p[i]][1] += dp[i][1]; } if (t[i] == 2) { dp[p[i]][0] = max(dp[p[i]][0] + dp[i][1], dp[p[i]][1] + dp[i][0]); dp[p[i]][1] += 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...