1117A.md (974B)
1 Source: https://codeforces.com/problemset/problem/1117/A 2 3 A. Best Subsegment 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding). 22 23 If there are many such subsegments find the longest one. 24 25 Input 26 27 The first line contains single integer $n$ ($1 \le n \le 10^5$) — length of the array $a$. 28 29 The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$) — the array $a$. 30 31 Output 32 33 Print the single integer — the length of the longest subsegment with maximum possible arithmetic mean. 34 35 Example 36 37 Input 38 39 ``` 40 5 41 6 1 6 6 0 42 ``` 43 44 Output 45 46 ``` 47 2 48 ``` 49 50 Note 51 52 The subsegment $[3, 4]$ is the longest among all subsegments with maximum arithmetic mean.