blob: 8ebae3381998518a207c269a3047909bb18c0820 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include <iostream>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
int current_count = 0;
int current_level_count = 1;
int current_level = 1;
long long current_sum = 0;
long long max_sum = -1000000;
int result = 1;
for (int i = 0; i < n; i++) {
long long a;
std::cin >> a;
current_sum += a;
current_count++;
if (current_count == current_level_count) {
if (current_sum > max_sum) {
max_sum = current_sum;
result = current_level;
}
current_count = 0;
current_level_count *= 2;
current_sum = 0;
current_level++;
}
}
if (current_count && current_sum > max_sum) {
result = current_level;
}
std::cout << result;
return 0;
}
|