题目大意
You are given a rooted tree, consisting of nnn vertices. The vertices in the tree are numbered from 111 to nnn, and the root is the vertex 111. The value aia_iai is written at the iii-th vertex.
You can perform the following operation any number of times (possibly zero): choose a vertex vvv which has at least one child; increase ava_vav by 111; and decrease aua_uau by 111 for all vertices uuu that are in the subtree of vvv (except vvv itself). However, after each operation, the values on all vertices should be non-negative.
Your task is to calculate the maximum possible value written at the root using the aforementioned operation.
给你一棵有根的树,由 nnn 个顶点组成。树中的顶点编号为 111 至 nnn ,根顶点为 111 。值 aia_iai 写在第 iii

最低0.47元/天 解锁文章
1626

被折叠的 条评论
为什么被折叠?



