🍑 最小权值
import java.util.Arrays;
public class Main
{
public static void main(String[] args)
{
long[] f = new long[4000];
Arrays.fill(f, Long.MAX_VALUE);
f[0] = 0;
for (int i = 1; i <= 2021; i++)// 枚举根节点
for (int j = 0; j < i; j++)// 枚举左子树的节点数
f[i] = Math.min(f[i], 1 + 2 * f[j] + 3 * f[i - j - 1] + j * j * (i - j - 1));
System.out.println(f[2021]);
}
}