#P13796. [SWERC 2023] Nicest view

[SWERC 2023] Nicest view

题目描述

:::align{center}

:::

Paris is so crowded with tourists during the Olympic games! You want to escape the city and go on a hike on a linear trail path, going from left to right. Every kilometre on that trail, including at start and end, is a milestone, on which is written the stone's altitude. The slope between two consecutive stones is constant, and no two stones have the same altitude.

Planning to come back with your friends, you try to identify the point of the hike at which you had the nicest view. The beauty of a point of view is defined as the distance (measured in kilometres) between your position and the leftmost position that you can see on your hike and that is at the same altitude as you are. If such a previous position fails to exist, it means that you can see the city and its smog, and the beauty of that view is zero.

You have listed the altitudes of the milestones. What is the maximal beauty on your hike?

输入格式

The input consists of two lines. The first line contains a single integer NN, which is the number of milestones on the trail path. The second line contains NN space-separated integers H1,H2,,HNH_1, H_2, \dots, H_N; each integer HkH_k is the altitude (measured in metres) of the kthk^\text{th} milestone on the path.

Limits

  • 1N100 0001 \leq N \leq 100~000;
  • 0Hk1 000 0000 \leq H_k \leq 1~000~000 for all kNk \leq N;
  • the integers HkH_k are pairwise distinct.

输出格式

The output should contain a single line, consisting of a single number SS: the best beauty score on your hike. This number is written either as an integer or as an irreducible fraction N/DN/D for which D2D \geq 2; we recall that a fraction N/DN/D is irreducible when the greatest common divisor of NN and DD is 11.

7
0 5 3 1 4 8 2
13/4
5
3 5 8 7 1
0