atcoder#ABC267G. [ABC267G] Increasing K Times
[ABC267G] Increasing K Times
Score : points
Problem Statement
You are given an integer sequence of length .
Find the number, modulo , of permutations of such that:
- there exist exactly integers between and (inclusive) such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4 2
1 1 2 2
4
Four permutations satisfy the condition: $P = (1, 3, 2, 4), (1, 4, 2, 3), (2, 3, 1, 4), (2, 4, 1, 3)$.
10 3
3 1 4 1 5 9 2 6 5 3
697112