#QHD0000078. Chia nhóm lập trình viên (Coding Company)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chia nhóm lập trình viên (Coding Company)
Coding Company
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
A company employs distinct coders. Coder has skill level . Partition all coders into nonempty teams so that every coder belongs to exactly one team; the number of teams is unrestricted.
The penalty of a team is the difference between its maximum and minimum skill levels, . A singleton team has penalty . The total penalty is the sum over all teams.
Two partitions are different if some pair of coders belongs to the same team in exactly one partition. The order of teams and the order within each team do not matter. Equal skill levels do not make coders indistinguishable.
Count the partitions whose total penalty is at most . Print the count modulo .
Input
The first line contains integers . The second line contains integers .
Output
Print one integer: the number of valid partitions modulo .
Subtasks
-
Subtask 1 (20 points): , , .
-
Subtask 2 (30 points): , , .
-
Subtask 3 (50 points): , , .
Examples
Example 1
Input
3 2
2 5 3
Output
3
Explanation
The three valid partitions are all singletons, team plus the singleton with skill , and team plus the singleton with skill .
Example 2
Input
3 0
4 4 4
Output
5
Explanation
All three coders share the same skill, so all five set partitions of three distinct coders have penalty .