Laziness of Killjee
All submissions for this problem are available.
Saraff best friend of Killjee recently gave a problem to Killjee. Killjee being too lazy is asking you out to help him.
You are given a number N and an array A of size M. You are supposed to find number of permutations of 1,2,3,......,N which has array A as its subsequence.
First line of Input contains two space separated integers N. Next line contains M space separated integers, elements of array A
Print a single integer number of permutations which satisfies above rules.As, answer can be very large print it %10^9+7
- 1 ≤ N ≤ 10^7
- 1 ≤ M ≤ 10^6
- 1 ≤ Ai ≤ N
Input: 5 4 1 3 4 5 Output: 5
Example case 1.1,2,3,4,52,1,3,4,51,3,2,4,51,3,4,2,51,3,4,5,2 These are 5 permutations which has array A as subsequence.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions