模拟
$O(n)$
边读入边计算,要注意每个点的大小,以及最好用long long存,否则大小可能会爆
C++ 代码
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll n;
int main(){
ll res=-(1<<30), d;
cin>>n;
ll t=1;
ll cnt=1;
for(ll i=n;i>0;){
ll sum=0;
for(ll j=1;j<=t&&j<=i;j++){
ll x;
cin>>x;
sum+=x;
}
if(sum>res){
res=sum;
d=cnt;
}
i-=t;
t<<=1;cnt++;
}
cout<<d;
return 0;
}