完全二叉树
注意:评测用例规模和约定中有负数!
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int depth = 1, m_depth;//深度和记录最大权值的深度
int length = 1;//每一层的长度,均小于deep * 2
int max = -1000000;
for (int i = 0; i < n; depth++, length *= 2)
{
int sum = 0;//每一层的权值
for (int j = 0; j < length && i < n; j++, i++)//每层
{
int x;
cin >> x;
sum += x;
}
if (sum > max)
{
max = sum;
m_depth = depth;
}
}
cout << m_depth << endl;
return 0;
}