#K14661. Conference Session Capacity Verification

    ID: 24185 Type: Default 1000ms 256MiB

Conference Session Capacity Verification

Conference Session Capacity Verification

You are given the schedule of several conference rooms. Each room hosts one or more sessions. A room's information is given by the number of sessions, its maximum capacity, and the details of each session. Each session is represented by its start time and duration. An attendee's schedule consists of a list of sessions they plan to attend, where each session is identified by the room number and its start time.

Your task is to verify if the schedule respects the maximum occupancy for every session in every room. In other words, for each session \( (s, d) \) in a room with capacity \( C \), if the number of attendees that chose the session exceeds \( C \) then the schedule is invalid. Otherwise, it is valid.

Print YES if the schedule is valid (no session exceeds capacity), or NO if any session exceeds its maximum capacity.

inputFormat

The input is given via standard input (stdin) and has the following format:

 n
 room_1_info
 room_2_info
 ...
 room_n_info
 k
 attendee_1_info
 attendee_2_info
 ...
 attendee_k_info

Here:

  • n is the number of conference rooms.
  • Each room_i_info consists of: r cap s1 d1 s2 d2 ... sr dr, where r is the number of sessions in the room, cap is the maximum capacity of the room, and for each session, s_j is the session start time and d_j its duration. The session ends at time \( s_j + d_j \).
  • k is the number of attendees.
  • Each attendee_i_info consists of: m r1 s1 r2 s2 ... rm sm, where m is the number of sessions the attendee will attend. For each session, r denotes the room number and s is the start time of the session the attendee participates in.

outputFormat

Output a single line to standard output (stdout):

  • YES if the schedule is valid (no session exceeds its capacity).
  • NO otherwise.
## sample
2
2 10 0 60 120 60
1 5 60 60
3
2 1 0 2 60
1 1 120
2 1 60 2 60
YES