Mock CCC '18 Contest 5 J3/S1 - Median Triples

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Given a list A of N integers, compute the number of triples (i,j,k) with i<j<k such that the median of Ai, Aj, and Ak is X.

Constraints

1N,X100

1ai100

Input Specification

The first line of the input consists of two space-separated integers, N and X.

The next line contains N space-separated integers, the values A1 through AN representing the N numbers of the list in order.

Output Specification

Output, on a single line, the number of valid triples.

Sample Input

Copy
4 1
1 1 2 2

Sample Output

Copy
2

Comments

There are no comments at the moment.