Master of Array Construction
Time limit4sMemory limit1024 MB
Count the ways to replace each 0 in an array of length N with a value from 1 to N so that each value x appears at most x times, modulo 998244353.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
An array of length consists of integers from to .
Jiro wants to replace every element with value with an integer from to . The resulting array must satisfy the following condition.
- For each integer from to , the number of times appears in array is at most .
Find the number of arrays Jiro can build that satisfy the condition, modulo . is prime.
Input
The first line contains the length of array . ()
The second line contains , separated by spaces. ()
Output
Print the number of arrays Jiro can build that satisfy the condition, modulo .