제출 #797314

#제출 시각아이디문제언어결과실행 시간메모리
797314Sohsoh84친구 (IOI14_friend)C++17
100 / 100
24 ms3404 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << ": " << x << endl; const int MAXN = 1e5 + 10; int C[MAXN], P[MAXN], Q[MAXN]; int findSample(int n, int C_[], int host[], int protocol[]){ for (int i = 0; i < n; i++) P[i] = C_[i]; for (int i = n - 1; i > 0; i--) { int h = host[i]; if (protocol[i] == 2) { P[h] = max(P[h] + Q[i], P[i] + Q[h]); Q[h] = Q[i] + Q[h]; } else if (protocol[i] == 1) { P[h] = max({P[h] + P[i], P[h] + Q[i], P[i] + Q[h]}); Q[h] = Q[i] + Q[h]; } else { P[h] = P[h] + Q[i]; Q[h] = Q[h] + max(P[i], Q[i]); } P[h] = max(P[h], Q[h]); } return max(Q[0], P[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...