問題一覧 > 通常問題

No.1294 Mountain Sequence

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 47
作問者 : 沙耶花 / テスター : tko919
お気に入りにしたユーザー ProblemId : 4473 / 自分の提出
問題文最終更新日: 2020-10-04 20:56:50
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 275 (順位表) の他の問題:

Problem Statement

A sequence obtained by concatenating a monotonically increasing sequence $X$ and a monotonically decreasing sequence $Y$, in this order, is called a mountain sequence.

Also, for a mountain sequence $\{x_1,x_2,...,x_n\}$ of length at least 2,
the maximum value among $|x_1 - x_2|,|x_2-x_3|,...,|x_{n-1}-x_n|$ is called the danger level of the sequence.
For example, the sequences $\{3, 7, 9, 4\}$ and $\{1, 2,4\}$ are both mountain sequences, and their danger levels are 5 and 2, respectively.

You are given a sequence of pairwise distinct positive integers $\{A_1,A_2,...,A_N\}$.
Find the danger level of every mountain sequence that can be obtained by rearranging it,
and output their sum $\bmod 998244353$.

Input

$N$
$A_1\ A_2\ ...\ A_N$

  • $2 \le N \le 2500$
  • $1 \le A_1 < A_2 < ... < A_N \le 2500$
  • All inputs are integers

Output

Output the answer.
Print a newline at the end.

Sample

Sample 1
Input
3
1 2 4
Output
10

The mountain sequences obtainable by rearranging are the following 4: $\{1,2,4\},\{1,4,2\},\{2,4,1\},\{4,2,1\}$.
Their danger levels are 2, 3, 3, 2 in this order, so output their sum, 10.

Sample 2
Input
4
3 4 7 9
Output
38

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。