Time limit: 1.5s
Memory limit: 256MB
Input:
Output:
Task
You are given an array of elements. We define an inversion as a pair of indices where and .
An operation is defined as the removal of an element.
You need to print the number of ways to perform a maximum of 2 operations such that the remaining array has exactly inversions.
Input data
The first line of input contains two numbers, and . These represent the number of elements in the array and the desired number of inversions after performing the operations, respectively. The second line contains elements representing the array .
Output data
Print the total number of ways to remove elements.
Constraints and clarifications
- , for
Subtasks
- For 15 points, .
- For another 20 points, .
- For another 20 points, şi .
- For another 45 points, .
Example 1
stdin
6 2
1 5 2 3 4 1
stdout
6
Explanation
The ways to remove two elements are: , , , , , .
Example 2
stdin
8 16
1 5 4 5 2 1 1 1
stdout
2
Explanation
The two ways are either not to remove any element or to remove the first element.