제출 #1002338

#제출 시각아이디문제언어결과실행 시간메모리
1002338ZeroCool친구 (IOI14_friend)C++14
100 / 100
17 ms3428 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define ar array // Find out best sample int findSample(int n,int A[],int host[],int p[]){ ar<int, 2> ans[n]; for(int i = 0;i < n;i++)ans[i] = {A[i], 0}; for(int i = n- 1;i >= 1;i--){ int j = host[i]; if(p[i] == 0){ ans[j][0] += ans[i][1]; ans[j][0] = max(ans[j][0], ans[i][0] + ans[j][1]); ans[j][1] += max(ans[i][0], ans[i][1]); } else if(p[i] == 1){ ans[j][0] += max(ans[i][0], ans[i][1]); ans[j][1] += ans[i][1]; }else{ ans[j][0] += ans[i][1]; ans[j][0] = max(ans[j][0], ans[i][0] + ans[j][1]); ans[j][1] += ans[i][1]; } } return max(ans[0][0], ans[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...