#P8681. [蓝桥杯 2019 省 AB] 完全二叉树的权值
[蓝桥杯 2019 省 AB] 完全二叉树的权值
Description
Given a complete binary tree with nodes, each node has a weight. In the order from top to bottom and from left to right, the weights are , as shown in the figure below:

Now Xiaoming wants to add up the weights of nodes at the same depth. He wants to know at which depth the sum of node weights is the largest. If there are multiple depths whose sums are tied for the largest, output the smallest such depth.
Note: The depth of the root is .
Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output one integer representing the answer.
7
1 6 5 4 3 2 1
2
Hint
For all testdata, , and .
Lanqiao Cup 2019 NOI Qualifier, Group A Problem F (Group B Problem G).
Translated by ChatGPT 5
京公网安备 11011102002149号