Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <stdio.h>struct _tree{int children ;int brother ;int parent ;long long int time ;long long int a ;} ;struct _tree tree[101000] ;long long int solve( int tag ){int p ;long long int cost ;long long int max = -1 ;p = tree[tag].children ;long long int ret = 0 ;int childrenCnt = 0 ;long long int sum = 0 ;while ( p != -1 ){ret += solve( p ) ;if ( tree[p].time > max )max = tree[p].time ;++childrenCnt ;sum += tree[p].time ;p = tree[p].brother ;}