Mock CCC '18 Contest 5 J3/S1 - Carol's Cute Center

View as PDF

Submit solution



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

Problem type

Mastering the art of counting spikes was a tough activity for Carol, but she did it gracefully and uneventfully.

Even though she was successfully able to count the spikes on all of the cacti and figure out the most frequent counts of spikes for her cacti, she still did not feel as though this provided her with an adequate reservoir of cuteness that she could rely on.

Desperate for more statistics from which she can derive cuteness, Carol starts attempting to study math. She learns about how to compute the mean of a sequence of integers, but does not like the word mean since it could have other implications.

In pursuit of the perfect statistics, Carol ended up finding balance in the one statistic that is the most resistant - the median. She chooses not to think too hard about the fact that mean is a subsequence of median.

A refresher for those who are unfamiliar with median - given values a_1 through a_{2n-1} in sorted order, the median is a_n.

Not one to easily switch out of nurturing mode, Carol wants to select three cacti such that the median number of spikes among the three cacti is X. Given all of the cacti that Carol owns, count how many distinct sets of three cacti Carol can select such that the median number of spikes on the three cacti is X. Keep in mind that even if cacti have the same number of spikes, that does not make them identical.

Constraints

1 \le N, X \le 100

1 \le a_i \le 100

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 a_1 through a_n representing the number of spikes on the ith cactus.

Output Specification

Output, on a single line, the number of sets of three cacti Carol can select such that the median number of spikes among the selected three cacti is X.

Sample Input

4 1
1 1 2 2

Sample Output

2

Comments

There are no comments at the moment.