Teams Creation
Time limit2sMemory limit512 MB
Count the ways to partition n students into exactly k unnumbered teams so that any two teams are separated by a threshold on skill level.
- Level
Medium7 of 10
- Topics
- Combinatorics, Sorting, Dynamic programming, Math
- Solved
- No attempts yet
Problem
Dr Emmett Brown changed jobs and now teaches computer science at a high school. His class has students, and he wants to run a programming contest for them. The classroom has only computers, so the contest has to be a team contest.
Dr Brown believes that a team works well when everyone on it has a similar skill level. He knows the skill level of every student. He wants to split the class so that for any two teams there is a number with the following property. Every student on one of the two teams has skill level at most , and every student on the other team has skill level at least . There must be exactly teams, every team must have at least one student, and there is no upper limit on the size of a team.
Count the ways to form the teams. Teams are not numbered. Two ways are different if some two students are on the same team in one of them and on different teams in the other. Report the count modulo .
Input
The first line contains two integers and (), the number of students in the class and the number of teams that must be created.
The second line contains integers (), the skill levels of all students.
Output
Print one integer, the number of ways to create the teams modulo .