제출 #392352

#제출 시각아이디문제언어결과실행 시간메모리
392352rainboy친구 (IOI14_friend)C11
100 / 100
33 ms3116 KiB
#include "friend.h" #include <string.h> #define N 100000 int max(int a, int b) { return a > b ? a : b; } int findSample(int n, int *aa, int *pp, int *tt) { static int dp[N], dq[N]; int i; memcpy(dp, aa, n * sizeof *aa); for (i = n - 1; i >= 0; i--) if (i > 0) { if (tt[i] == 0) dp[pp[i]] += dq[i], dq[pp[i]] += max(dp[i], dq[i]); else if (tt[i] == 1) dp[pp[i]] = max(dp[pp[i]] + max(dp[i], dq[i]), dq[pp[i]] + dp[i]), dq[pp[i]] += dq[i]; else dp[pp[i]] = max(dp[pp[i]] + dq[i], dq[pp[i]] + dp[i]), dq[pp[i]] += dq[i]; } return max(dp[0], dq[0]); }
#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...