Submission #173056

#TimeUsernameProblemLanguageResultExecution timeMemory
173056maximath_1Friend (IOI14_friend)C++11
100 / 100
38 ms3448 KiB
#include"friend.h" #include<bits/stdc++.h> using namespace std; int findSample(int n, int c[], int h[], int p[]){ int ans[n], alt[n]; memset(alt, 0, sizeof(alt)); for(int i=0; i<n; i++) ans[i]=c[i]; for(int i=n-1; i>0; i--){ if(p[i]==0){ ans[h[i]]+=alt[i]; alt[h[i]]+=ans[i]; }else if(p[i]==1){ ans[h[i]]+=ans[i]; alt[h[i]]+=alt[i]; }else if(p[i]==2){ ans[h[i]]=max(ans[h[i]]+alt[i], alt[h[i]]+ans[i]); alt[h[i]]+=alt[i]; } ans[h[i]]=max(ans[h[i]], alt[h[i]]); } return ans[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...