Code coloring overdose
Practice
4 (58 votes)
Ready
Mathematics
Dynamic programming
Medium
Problem
88% Success 488 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Little Pandey has N colorless balls. His best friend GJ has K colors, numbered from 1 to K. Little Pandey assigns to GJ the task of coloring each ball, as GJ is a little free these days. For the i-th ball GJ chooses color Ci.

But, Little Pandey is tired and bored after the trip. He decides to find the total number of some special subsets of balls - subsets containing balls of at most M distinct colors. This task is too complicated to handle for Pandey's tired mind, so he asks for your help, since he cannot expect a lot of help from GJ!

Input format:
The first line of the input consists of three integers N, K and M. The next line consists of N integers C1 , C2 ... CN denoting colors of balls.

Output format:
Print the total number of subsets such that each subset contains balls of at most M distinct colors. Output it modulus 109 + 7, i.e., 1000000007.

Constraints:
1 ≤ K, N ≤ 5*105
1≤ M ≤ 10
1 ≤ Ci ≤ K

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
Dynamic ProgrammingOpenApprovedMathMedium
Points:30
9 votes
Tags:
Dynamic ProgrammingCombinatoricsMediumMathematicsOpenApproved
Points:20
117 votes
Tags:
ApprovedEasyMathNumber TheoryOpen