【动态规划】之树形DP例题2024/7/10codeforces Div.2 T4《Maximize the Root》

题目大意

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 个顶点组成。树中的顶点编号为 111nnn ,根顶点为 111 。值 aia_iai 写在第 iii

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值