Your code here...
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dfs(int u)
{
if(son[u]==0)
return value[u];
if(son[u]==1)
return (value[u]+dfs(v))>>1;
if(son[u]>1)
{
ll minn=MAX_LONG_LONG;
for(v|u->v)
{
minn=min(dfs(v),minn);
}
return minn;
}
}
int main()
{
cout<<value[1]+dfs(1)<<endl;
return 0;
}