#P7322. Permutation Sliding Window Distinct Maximums Sum
Permutation Sliding Window Distinct Maximums Sum
Permutation Sliding Window Distinct Maximums Sum
Given two positive integers n and k, consider all permutations p of length n consisting of the integers from 1 to n. For a permutation p, define a sequence f(p) as follows:
$$f(p)=\{\max_{1\le i\le k}\{p_i\},\; \max_{2\le i\le k+1}\{p_i\},\; \cdots,\; \max_{n-k+1\le i\le n}\{p_i\}\} $$Define the weight w(a) of any sequence a as the number of distinct elements in a. The task is to compute the sum of w(f(p)) over all permutations p of length n.
Note: All formulas are provided in \(\LaTeX\) format.
inputFormat
The input consists of a single line containing two integers n and k separated by a space, where:
- n (1 ≤ n ≤ 10) is the length of the permutation. (Small bounds are assumed so that a brute-force solution is feasible.)
- k (1 ≤ k ≤ n) is the window length.
outputFormat
Output a single integer, which is the sum of w(f(p)) computed over all permutations p of length n.
sample
3 2
10