제출 #927457

#제출 시각아이디문제언어결과실행 시간메모리
927457Gilwall친구 (IOI14_friend)C++14
100 / 100
20 ms3160 KiB
#include "friend.h" #include <vector> using namespace std; // Find out best sample int findSample(int n, int confidence[], int host[], int protocol[]){ vector<int> M(n), NM(n); for(int i = 0; i < n; i++) { M[i] = confidence[i]; NM[i] = 0; } for(int i = n-1; i > 0; i--) { // i is person being added int x = host[i]; int y = i; if (protocol[i] == 0) { NM[x] += max(M[y], NM[y]); M[x] += NM[y]; } else if (protocol[i] == 1) { // My friends are yours //int mx = max(NM[x], M[x]) + max(NM[y], M[y]); int mx = max(M[x] + M[y], max(NM[x] + M[y], NM[y] + M[x])); int nmx = NM[x] + NM[y]; M[x] = mx; NM[x] = nmx; } else if (protocol[i] == 2) { // We are all friends int mx = max(NM[x] + M[y], NM[y] + M[x]); int nmx = NM[x] + NM[y]; M[x] = mx; NM[x] = nmx; } } return max(M[0], NM[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...