PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000020. Đếm dãy con tăng đúng K phần tử (INCSEQ - Increasing Subsequences)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm dãy con tăng đúng K phần tử (INCSEQ - Increasing Subsequences)

INCSEQ - Increasing Subsequences

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn integers, choose exactly kk indices i1<i2<⋯<iki_1<i_2<\cdots<i_k such that ai1<ai2<⋯<aika_{i_1}<a_{i_2}<\cdots<a_{i_k}. Count all such choices of positions, even if two different choices yield identical values. Print the count modulo 5 000 0005\,000\,000.

Input

The first line contains integers n,kn,k. It is followed by exactly nn integers a1,…,ana_1,\ldots,a_n in order, possibly on separate lines.

Output

Print one integer: the number of strictly increasing subsequences of length exactly kk, modulo 5 000 0005\,000\,000.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤k≤41\le k\le 4 and k≤nk\le n; 0≤ai<1050\le a_i<10^5 for every ii.
  • Subtask 2 (30 points): 1≤n≤7001\le n\le 700; 1≤k≤201\le k\le 20 and k≤nk\le n; 0≤ai<1050\le a_i<10^5 for every ii.
  • Subtask 3 (50 points): 1≤n≤100001\le n\le 10000; 1≤k≤501\le k\le 50 and k≤nk\le n; 0≤ai<1050\le a_i<10^5 for every ii.

Examples

Input

4 3
1
2
2
10

Output

2

Explanation

A length-three increasing subsequence must begin with 11 and end with 1010. The middle element can be the 22 at position 22 or the 22 at position 33. Thus the two index triples (1,2,4)(1,2,4) and (1,3,4)(1,3,4) are counted, giving 22.