#C7852. Project Assignment Feasibility

    ID: 51769 Type: Default 1000ms 256MiB

Project Assignment Feasibility

Project Assignment Feasibility

You are given several test cases. For each test case, you are provided with the number of employees n and the maximum number of hours m that each employee can work per week. Additionally, each test case contains a list of projects where each project requires a certain number of hours to complete.

Your task is to determine whether it is possible to assign all projects to the employees without any employee exceeding the weekly hour limit. In other words, for each test case, you need to check if the total sum of required hours for all projects is at most n × m.

Note: The input is read from stdin and the output should be printed to stdout.

The decision for each test case should be output on a separate line as "YES" if it is possible to assign the projects without exceeding the limit, or "NO" otherwise.

inputFormat

The input starts with an integer T representing the number of test cases. For each test case, the input is given as follows:

  • A line with two integers n and m, where n is the number of employees and m is the maximum weekly work hours per employee.
  • A line with an integer k representing the number of projects.
  • A line with k space-separated integers, representing the required hours for each project.

All input is provided via stdin.

outputFormat

For each test case, output a single line containing YES if it is possible to complete all projects without any employee exceeding m hours per week (i.e. if the total hours required is at most n * m), otherwise output NO.

The output should be printed to stdout.

## sample
4
3 10
3
4 6 2
5 20
5
5 5 5 5 5
2 8
2
10 10
4 15
4
3 3 3 3
YES

YES NO YES

</p>