Nicest view

시간 제한0.25초메모리 제한1024 MB

요약
각 킬로미터 지점의 고도가 모두 다를 때, 같은 고도를 가진 두 지점 사이 거리의 최댓값을 구한다.
난이도

보통10점 중 5점

유형
해시맵, 배열
정답자
아직 제출이 없습니다

문제

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. 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 previous position, on your hike, that was at the same altitude. 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 H_1,H_2,…,H_NH\_1, H\_2, \dots , H\_N; each integer H_kH\_k is the altitude (measured in metres) of the kkth milestone on the path.

출력

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 D≥2D \ge 2; we recall that a fraction N/DN/D is irreducible when the greatest common divisor of NN and DD is 11.

제한

  • 1≤N≤100,0001 \le N \le 100\\, 000
  • 0≤H_k≤1,000,0000 \le H\_k \le 1\\, 000\\, 000 for all k≤Nk \le N
  • the integers H_kH\_k are pairwise distinct.

예제2

  1. 예제 1

    입력
    7
    0 5 3 1 4 8 2
    
    예상 출력
    13/4
    
  2. 예제 2

    입력
    5
    3 5 8 7 1
    
    예상 출력
    0