Logo
(追記) (追記ここまで)

33451번 - Count the Orders 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB108360.000%

문제

There are $n$ positions on a circle, numbered successively by integers from 1ドル$ to $n$. The positions $i$ and $i + 1$ are adjacent; the positions $n$ and 1ドル$ are also adjacent.

Consider $n$ distinct integers $a_1, a_2, \ldots, a_n$. We arrange them somehow on the circle, so that there is a single integer in each of the $n$ positions. The cost of an arrangement is defined as the sum of the absolute values of the difference between every two adjacent integers.

Two arrangements are different if and only if at least one integer has different positions in them.

You need to find the maximum cost of an arrangement. Additionally, calculate the number of different arrangements that have this cost. As their number can be very large, find it modulo 10ドル^9 + 7$.

입력

The first line contains a single integer $n$ (3ドル \le n \le 10^6$).

The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ (0ドル \le a_i \le 10^9$).

It is guaranteed that $a_1, a_2, \ldots, a_n$ are pairwise distinct.

출력

Output a single line with two integers. The first one should be the maximum cost. The second one should be the number of different arrangements that have this cost, modulo 10ドル^9 + 7$.

제한

예제 입력 1

3
1 2 3

예제 출력 1

4 6

예제 입력 2

4
2 4 8 16

예제 출력 2

36 8

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 4: Peking U Contest 2 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /