Median

All submissions for this problem are available.
###Read problems statements [Mandarin](http://www.codechef.com/download/translated/LTIME66/mandarin/MDN.pdf) , [Bengali](http://www.codechef.com/download/translated/LTIME66/bengali/MDN.pdf) , [Hindi](http://www.codechef.com/download/translated/LTIME66/hindi/MDN.pdf) , [Russian](http://www.codechef.com/download/translated/LTIME66/russian/MDN.pdf) and [Vietnamese](http://www.codechef.com/download/translated/LTIME66/vietnamese/MDN.pdf) as well. You are given an integer sequence $A_1, A_2, \dots, A_N$ and integers $K$ and $M$. For $1 \le i \le j \le N$, let's define $S(i, j)$ as the number of ways to choose exactly $K$ elements of the contiguous subsequence $A_i, A_{i+1}, \dots, A_j$ in such a way that the median of these $K$ elements is $\ge M$. Find the sum of $S(i, j)$ over all $i, j$ such that $1 \le i \le j \le N$. Since this sum may be large, calculate it modulo $10^9+7$. ### Input  The first line of the input contains three spaceseparated integers $N$, $K$ and $M$.  The second line contains $N$ spaceseparated integers $A_1, A_2, \dots, A_N$. ### Output Print a single line containing one integer — $\sum_{i=1}^N \sum_{j=i}^N S(i, j)$ modulo $10^9+7$. ### Constraints  $1 \le N \le 10^5$  $3 \le K \le 100$  $K$ is an odd number  $1 \le M \le 200$  $1 \le A_i \le 10^9$ for each valid $i$  all elements of $A$ are pairwise distinct ### Subtasks **Subtask #1 (30 points):**  $1 \le N \le 80$  $3 \le K \le 80$ **Subtask #2 (70 points):** original constraints ### Example Input ``` 4 3 2 1 2 3 4 ``` ### Example Output ``` 6 ``` ### Explanation $S(1,1) = S(1,2) = S(2,2) = S(2,3) = S(3,3) = S(3,4) = S(4,4) = 0$, $S(1,3) = S(2,4) = 1$ and $S(1,4) = 4$.Author:  nots0fast 
Tags  nots0fast 
Date Added:  21112018 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 