Submission #284622

#TimeUsernameProblemLanguageResultExecution timeMemory
284622eohomegrownappsFriend (IOI14_friend)C++14
100 / 100
38 ms3448 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ vector<int> take(n); vector<int> leave(n); for (int i = 0; i<n; i++){ take[i]=confidence[i]; } for (int i = n-1; i>0; i--){ //unmerge elements host[i] and i int x = i; int y = host[i]; int takenew, leavenew; if (protocol[i]==0){ //iamyourfriend takenew = take[y]+leave[x]; leavenew = max(leave[x]+leave[y], take[x]+leave[y]); } else if (protocol[i]==1){ //myfriendsareyourfriends takenew = max(take[x]+take[y], max(take[x]+leave[y], leave[x]+take[y])); leavenew = leave[x]+leave[y]; } else { //weareyourfriends takenew = max(take[x]+leave[y],take[y]+leave[x]); leavenew = leave[x]+leave[y]; } take[host[i]] = takenew; leave[host[i]] = leavenew; } return max(take[0],leave[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...