問題一覧 > 通常問題

No.3070 Collecting Coins Speedrun 2

レベル : / AI推定難易度 : 1175 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 103
作問者 : 👑 AngrySadEight / テスター : aplysiaSheep 👑 hamamu
お気に入りにしたユーザー ProblemId : 11902 / 自分の提出
問題文最終更新日: 2025-02-19 02:21:25
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 461 (順位表) の他の問題:

Problem Statement

There are $N$ coins on a number line. The $i$-th coin is at coordinate $c_i$. No $2$ coins are at the same coordinate.

You are initially at coordinate $0$. You may move a distance of $1$ in the positive or negative direction any number of times.

You can obtain a coin if and only if you are at the same coordinate as that coin.

Your goal is to collect all the coins and finally return to coordinate $0$. Let $M$ be the minimum possible total distance traveled needed to achieve this goal.

There are $N!$ orders in which all the coins can be obtained. Among them, find the number, modulo $998244353$, of orders of obtaining the coins for which there exists a way of moving with a total distance traveled of $M$.

Constraints

  • All inputs are integers
  • $1 \leq N \leq 10^5$
  • $-10^8 \leq c_1 < c_2 < \dots < c_N \leq 10^8$

Input

The input is given from Standard Input in the following format.

$N$
$c_1$ $c_2$ $\dots$ $c_N$

Output

Output the number, modulo $998244353$, of orders of obtaining the coins for which there exists a way of moving with a total distance traveled of $M$.

Sample

Sample 1
Input
3
-1 1 3
Output
4

By obtaining the $1$st, $3$rd, and $2$nd coins in this order, you move through the coordinates as $0 \rightarrow -1 \rightarrow 3 \rightarrow 1 \rightarrow 0$, and the total distance traveled is $1 + 4 + 2 + 1 = 8$. This is the minimum total distance traveled.

Note that you must return to coordinate $0$ after obtaining all the coins.

Letting $P$ be the order of obtaining the coins, there are $4$ orders $P$ for which there exists a way of moving with a total distance traveled of $8$: $P = (1, 2, 3), (1, 3, 2), (2, 3, 1), (3, 2, 1)$.

Sample 3
Input
5
-2 -1 0 1 2
Output
24
Sample 3
Input
37
-32 -30 -28 -27 -25 -24 -22 -20 -18 -17 -15 -13 -10 -9 -8 -5 -3 -2 1 3 6 7 8 9 11 12 14 16 19 22 23 24 26 28 30 32 36
Output
838860732

Output the answer modulo $998244353$.

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