大和証券プログラミングコンテスト2021 (AtCoder Regular Contest 128)
翻译中…
Problem Statement
翻译中…
There are $N$ cards numbered $1$ to $N$. Card $i$ has an integer $A_i$ written on it. Here, $N$ is even.
翻译中…
Snuke and Robot will play a game, which will go as follows.
翻译中…
- The game master announces a permutation
$(p_1,p_2,\cdots,p_N)$of$(1,2,\cdots,N)$, to both Snuke and Robot. - Then, Snuke and Robot alternately take turns, with Snuke going first. Each turn goes as follows.
- Snuke's turn: choose a remaining card of his choice and eat it.
- Robot's turn: choose Card
$i$with the largest$p_i$and burn it.
- Robot's turn: choose Card
- The game ends when there is no more card.
翻译中…
The final score of the game is the sum of integers written on the cards eaten by Snuke. Snuke will play optimally to maximize the score.
翻译中…
There are $N!$ permutations $p$ of $(1,2,\cdots,N)$. Find the sum, modulo $998244353$, of the final scores for all of these permutations.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 10^6$$N$is even.$1 \leq A_i \leq 10^9$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
2
1 2
Output #1
4
Regardless of the permutation $p$, Snuke will eat Card $2$.
Input #2
4
1 100 10000 1000000
Output #2
24200400
For example, when $p=(3,1,4,2)$, the game will go as follows.
- Snuke eats Card $3$.
- Robot burns Card $1$.
- Snuke eats Card $4$.
- Robot burns Card $2$.
The score of the game here is $1010000$.
Input #3
10
866111664 178537096 844917655 218662351 383133839 231371336 353498483 865935868 472381277 579910117
Output #3
710984634
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。