Submission #810292

#TimeUsernameProblemLanguageResultExecution timeMemory
810292KerimFriend (IOI14_friend)C++17
100 / 100
22 ms3140 KiB
#include "friend.h" #include "bits/stdc++.h" #define pb(x) push_back(x) using namespace std; const int MAXN = 1e5+5; int p[MAXN], q[MAXN]; int findSample(int n,int arr[],int host[],int protocol[]){ for (int i = 0; i < n; i++) p[i] = arr[i], q[i] = 0; for (int i = n-1; i > 0; i--){ int pp = protocol[i]; int v = host[i]; if (pp == 2){ //WeAreYourFriends p[v] = max(p[v] + q[i], p[i] + q[v]); q[v] = q[v] + q[i]; } else if (pp == 1){//MyFriendsAreYourFriends p[v] = max(p[v]+p[i], max(p[v] + q[i], p[i] + q[v])); q[v] = q[v] + q[i]; } else{//IamYourFriend p[v] = p[v] + q[i]; q[v] = max(p[i] + q[v], q[v] + q[i]); } } return max(p[0], q[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...