제출 #168613

#제출 시각아이디문제언어결과실행 시간메모리
168613johutha친구 (IOI14_friend)C++14
100 / 100
39 ms4456 KiB
#include "friend.h" #include <vector> #include <iostream> #include <algorithm> #define int int64_t using namespace std; // Find out best sample signed findSample(signed n, signed confidence[], signed host[], signed protocol[]) { vector<int> take; for (int i = 0; i < n; i++) take.push_back(confidence[i]); vector<int> nottake(n, 0); for (int i = n - 1; i > 0; i--) { int hs = host[i]; if (protocol[i] == 0) { take[hs] += nottake[i]; nottake[hs] += max(take[i], nottake[i]); } else if (protocol[i] == 1) { take[hs] = max(take[hs] + max(take[i], nottake[i]), nottake[hs] + take[i]); nottake[hs] += nottake[i]; } else { take[hs] = max(take[hs] + nottake[i], take[i] + nottake[hs]); nottake[hs] += nottake[i]; } } return max(take[0], nottake[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...