How Many Permutation?
题号:NC273392
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Given a sequence of length n and a positive integer k, you can permute the sequence. The goal is to permute the sequence in such a way that the difference between any two adjacent elements is at least k. How many different permutations can achieve this goal? It is guaranteed that the n elements in the sequence are all distinct.

输入描述:

The first line contains two integers n (1\leq n \leq 8) and k (1\leq k\leq 20), representing the length of the sequence and the difference value, respectively.
The second line contains n integers a_1, a_2, ..., a_n (1\leq a_i\leq 20), representing the elements in the sequence.

输出描述:

Output an integer in a single line, representing the number of permutations that achieve the goal.
示例1

输入

复制
3 2
1 2 4

输出

复制
2

说明

In the example, only permutaions [1, 4, 2] and [2, 4, 1] achieve the goal.