atcoder#ARC128F. [ARC128F] Game against Robot
[ARC128F] Game against Robot
Score : points
Problem Statement
There are cards numbered to . Card has an integer written on it. Here, is even.
Snuke and Robot will play a game, which will go as follows.
- The game master announces a permutation of , 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 with the largest and burn it.
- Snuke's turn: choose a remaining card of his choice and eat it.
- Robot's turn: choose Card with the largest and burn it.
- 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 permutations of . Find the sum, modulo , of the final scores for all of these permutations.
Constraints
- is even.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2
1 2
4
Regardless of the permutation , Snuke will eat Card .
4
1 100 10000 1000000
24200400
For example, when , the game will go as follows.
- Snuke eats Card .
- Robot burns Card .
- Snuke eats Card .
- Robot burns Card .
The score of the game here is .
10
866111664 178537096 844917655 218662351 383133839 231371336 353498483 865935868 472381277 579910117
710984634