#K65277. Concert Assignment Problem

    ID: 32162 Type: Default 1000ms 256MiB

Concert Assignment Problem

Concert Assignment Problem

You are given N concerts and M arenas. For each concert, an expected attendance is provided, and for each arena, a capacity is given. Your task is to determine whether it is possible to assign each concert to an arena such that the expected attendance of the concert does not exceed the capacity of the arena assigned.

Formally, given two sequences:

  • \( A = [a_1, a_2, \dots, a_N] \) where \( a_i \) denotes the expected attendance for the \( i^{th} \) concert
  • \( C = [c_1, c_2, \dots, c_M] \) where \( c_j \) denotes the capacity of the \( j^{th} \) arena

You need to decide if there exists an assignment of concerts to arenas (each arena can host at most one concert) such that for every assigned pair \( (a_i, c_j) \), it holds that \( a_i \leq c_j \). Output "YES" if such an assignment exists, and "NO" otherwise.

inputFormat

The input is read from standard input (stdin) and has the following format:

N M
expected_attendance_1 expected_attendance_2 ... expected_attendance_N
arena_capacity_1 arena_capacity_2 ... arena_capacity_M

Where:

  • N is the number of concerts.
  • M is the number of arenas.
  • The second line contains N space-separated integers representing the expected attendance for each concert.
  • The third line contains M space-separated integers representing the capacities of the arenas.

outputFormat

Output to standard output (stdout) a single line containing either "YES" if it is possible to assign each concert to a suitable arena or "NO" if it is not.

## sample
3 3
100 200 300
300 100 200
YES