Submission #704568

#TimeUsernameProblemLanguageResultExecution timeMemory
704568jamezzzFriend (IOI14_friend)C++17
100 / 100
24 ms3404 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define maxn 100005 int take[maxn],notake[maxn]; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=0;i<n;++i)take[i]=confidence[i]; for(int i=n-1;i>0;--i){ int h=host[i]; if(protocol[i]==0){//i am your friend take[h]+=notake[i]; notake[h]+=max(take[i],notake[i]); } else if(protocol[i]==1){//my friends are your friends take[h]=max(take[h]+take[i],max(take[h]+notake[i],notake[h]+take[i])); notake[h]+=notake[i]; } else{//we are your friends take[h]=max(take[h]+notake[i],notake[h]+take[i]); notake[h]+=notake[i]; } } return max(take[0],notake[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...