#P17282. 「IXOI R2」跟你爆了

    ID: 19633 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>贪心洛谷原创O2优化洛谷月赛双指针 two-pointer

「IXOI R2」跟你爆了

Background

Your useless classmate is stuffing your head with meaningless information, so you decide you’re done with him.

Problem Description

Specifically, your classmate said nn pieces of nonsense. The ii-th piece contains information amount aia_i, so what he said can be seen as a sequence of length nn: a1ana_1 \dots a_n.

Define the information density of an interval [l,r][l, r] as the total information amount in this interval divided by the interval length. That is, the information density of a[lr]a_{[l \dots r]} is i=lrairl+1\dfrac{\sum_{i=l}^{r} a_i}{r - l + 1}.

To be done with your classmate, you decide to find the consecutive segment of his words with the lowest information density. In other words, you need to find a subinterval of the sequence such that the information density of this interval is minimized.

To avoid letting your classmate notice that you are picking a fight, this information density cannot be 00.

Input Format

The first line contains an integer nn, representing the number of nonsense statements your classmate said.

The second line contains nn space-separated integers a1ana_1 \dots a_n, representing the information amount of each statement.

Output Format

Output one line with two positive integers x,yx, y separated by a space, meaning that among all consecutive segments with non-zero information density, the minimum information density is xy\dfrac{x}{y}.

Note that the fraction xy\dfrac{x}{y} must be in lowest terms. In particular, if after simplification the result is an integer, then y=1y = 1.

5
0 2 0 1 0
1 3

Hint

This problem uses bundled testdata.

Subtask nn\le Special Property Score
11 500500 None 1010
22 10410^4
33 10610^6 Yes 3030
44 None 5050

Special property: It is guaranteed that there is only one value in the sequence that is greater than 00.

For all testdata, it is guaranteed that:

1n1061 \le n \le 10^6, 0ai1090 \le a_i \le 10^9, and the maximum value of the sequence is non-zero.

Translated by ChatGPT 5