# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16525 | eaststar | Friend (IOI14_friend) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <algorithm>
using namespace std;
int findSample(int n,int *c,int *h,int *p,int *b){
int i;
for(;--i;){
if(!p[i]){
c[h[i]]+=b[i];
b[h[i]]+=max(c[i],b[i]);
}
else if(p[i]==1){
c[h[i]]=max(c[h[i]]+max(c[i],b[i]),b[h[i]]+c[i]);
b[h[i]]+=b[i];
}
else{
c[h[i]]=max(c[h[i]]+b[i],b[h[i]]+c[i]);
b[h[i]]+=b[i];
}
}
return max(c[0],b[0]);
}