题解
2023-08-25 21:00:22
发布于:上海
111阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
int a[N];
int main(){
int n;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
int depth = 0;
ll maxx = -N;
for (int d = 1, i = 1; i <= n; i *= 2, d++){
ll sum = 0;
for (int j = i; j <= 2 * i - 1 && j <= n; j++){
sum += a[j];
}
if (sum >= maxx){
maxx = sum;
depth = d;
}
}
cout << depth << endl;
return 0;
}
这里空空如也
有帮助,赞一个