Submission #344721

#TimeUsernameProblemLanguageResultExecution timeMemory
344721pit4hFriend (IOI14_friend)C++14
100 / 100
34 ms3436 KiB
#include<bits/stdc++.h> #include "friend.h" using namespace std; const int MAXN = 1e5+1; int val[2][MAXN]; int findSample(int n, int confidence[], int host[], int protocol[]){ int ans = 0; for(int i=0; i<n; ++i) { val[0][i] = 0; val[1][i] = confidence[i]; } for(int i=n-1; i>=1; --i) { if(protocol[i]==0) { val[0][host[i]] += max(val[0][i], val[1][i]); val[1][host[i]] += val[0][i]; } if(protocol[i]==1) { val[1][host[i]] = max(val[0][host[i]], val[1][host[i]]) + max(val[0][i], val[1][i]); val[0][host[i]] += val[0][i]; } if(protocol[i]==2) { val[1][host[i]] = max({val[1][host[i]]+val[0][i], val[0][host[i]]+val[1][i], val[0][host[i]]+val[0][i]}); val[0][host[i]] += val[0][i]; } //cerr<<i<<": "<<val[0][1]<<' '<<val[1][1]<<'\n'; //cerr<<" "<<val[0][0]<<' '<<val[1][0]<<'\n'; } ans = max(val[0][0], val[1][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...