void shader::fill_array_values(gpr_array *a, vvec &vv) { unsigned sz = a->array_size; vv.resize(sz); for (unsigned i = 0; i < a->array_size; ++i) { vv[i] = get_gpr_value(true, a->base_gpr.sel() + i, a->base_gpr.chan(), false); } }
int main(){ int i, u, v; cin>>n; rel.resize(n+2); for( i=1 ; i<n ; i++ ){ cin>>u>>v; rel[u].pb(v); rel[v].pb(u); } total_sum = 0; for( i=1 ; i<=n ; i++ ){ cin>>c[i]; total_sum += c[i]; vis[i] = 0; } visited = 0; ans = -1; par[1] = 1; int cc = dfs(1); if( ans != -1 ){ cout<<"YES\n"; cout<<ans<<"\n"; } else{ cout<<"NO\n"; } return 0; }