Submission #423025

#TimeUsernameProblemLanguageResultExecution timeMemory
423025ocarimaFriend (IOI14_friend)C++14
100 / 100
33 ms3400 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; #define debugsl(x) cout << #x << " = " << x << ", " #define debug(x) debugsl(x) << "\n" #define MAX_N 1000002 #define yo 0 #define ellos 1 #define nosotros 2 int s[MAX_N], no[MAX_N]; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ int ans = 0; for(int i = 0; i < n; ++i) s[i] = confidence[i]; for(int i = n - 1; i > 0; --i){ if (protocol[i] == yo){ s[host[i]] += no[i]; no[host[i]] += max(s[i], no[i]); } else if (protocol[i] == ellos){ s[host[i]] = max(max(s[host[i]] + no[i], no[host[i]] + s[i]), s[host[i]] + s[i]); no[host[i]] += no[i]; } else if (protocol[i] == nosotros){ s[host[i]] = max(s[host[i]] + no[i], no[host[i]] + s[i]); no[host[i]] += no[i]; } } ans = max(s[0], no[0]); return ans; }
#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...