#C11461. Even Distribution of Employee Skill Levels

    ID: 40780 Type: Default 1000ms 256MiB

Even Distribution of Employee Skill Levels

Even Distribution of Employee Skill Levels

In this problem, you are given (D) departments and a total of (E) employees, where each department has a list of employee skill levels. You are allowed to redistribute the employees among the departments arbitrarily. Your task is to determine if it is possible to reassign the employees such that every department ends up having the same total skill level. Formally, if the sum of all skill levels is (S), then each department must have a total skill level of (\frac{S}{D}), which implies that (S \mod D = 0). If this basic divisibility condition holds, the problem reduces to partitioning the multiset of employee skill levels into (D) groups each with sum (\frac{S}{D}).

inputFormat

The first line of input contains two integers (D) and (E) separated by a space, where (D) denotes the number of departments and (E) is the total number of employees. This is followed by (D) lines; each line corresponds to one department and contains a space-separated list of integers representing the skill levels of the employees originally assigned to that department.

outputFormat

Output a single line containing either "YES" if it is possible to redistribute the employees so that every department has the same total skill level, or "NO" otherwise.## sample

3 6
10 20 30
30 10 20
20 30 10
YES