Submission #168611

#TimeUsernameProblemLanguageResultExecution timeMemory
168611johuthaFriend (IOI14_friend)C++14
0 / 100
2 ms380 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 = 1; i < n; i++) { int hs = host[i]; if (protocol[i] == 0) { take[i] += nottake[hs]; nottake[i] += max(take[hs], nottake[hs]); } else if (protocol[i] == 1) { take[i] = max(take[i] + max(take[hs], nottake[hs]), nottake[i] + take[hs]); nottake[i] += nottake[hs]; } else { take[i] = max(take[i] + nottake[hs], take[hs] + nottake[i]); nottake[i] += nottake[hs]; } } return max(take[n - 1], nottake[n - 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...