제출 #1022430

#제출 시각아이디문제언어결과실행 시간메모리
1022430blue친구 (IOI14_friend)C++17
100 / 100
19 ms3416 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> Yes(n, 0), No(n, 0); //dp if person i is chosen / not chosen for(int i = 0; i < n; i++) Yes[i] += confidence[i]; for(int i = n-1; i >= 1; i--) { if(protocol[i] == 0) //I am your friend { //yes i, yes host[i] //no i, yes host[i] Yes[ host[i] ] += No[i]; //yes i, no host[i] //no i, no host[i] No[ host[i] ] += max(Yes[i], No[i]); } else if(protocol[i] == 1) //My friends are your friends { //yes i, yes host[i] //no i, yes host[i] //yes i, no host[i] Yes[ host[i] ] = max(Yes[ host[i] ] + Yes[i], max(No[host[i]] + Yes[i], Yes[host[i]] + No[i])); // Yes[ host[i] ] = Yes[ host[i] ] + max(Yes[i], No[i]); //no i, no host[i] No[ host[i] ] += No[i]; } else //We are your friends { //yes i, yes host[i] //no i, yes host[i] //yes i, no host[i] Yes[ host[i] ] = max(Yes[ host[i] ] + No[i], No[ host[i] ] + Yes[i]); //no i, no host[i] No[ host[i] ] += No[i]; } } return max(Yes[0], No[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...