#C8697. Booth Scheduling Problem

    ID: 52707 Type: Default 1000ms 256MiB

Booth Scheduling Problem

Booth Scheduling Problem

You are given a set of booths and a list of participants with their scheduling requests. Each participant wants to visit a consecutive sequence of booths. For each participant, the request is represented by four integers: P, A, C, and d (although d is provided, it is not used in scheduling). A participant with request (P, A, C, d) will try to book P time slots for every booth from A to C (inclusive). A conflict occurs if, at any booth, the same time slot is booked by more than one participant.

Your task is to determine whether it is possible to schedule all participants so that no two participants occupy the same booth at the same time slot. Formally, for each booth b, if we let S_b be the set of booked time slots, then the schedule is valid if:

$$\forall b,\quad \forall t \; \; (t \text{ appears at most once in } S_b). $$

Output Yes if all participants can be scheduled without conflict, and No otherwise.

inputFormat

The input is read from standard input (stdin). The first line contains two integers B and M, where B is the total number of booths and M is the number of participants. The next M lines each contain four integers: P, A, C, and d. Here, P denotes the number of time slots a participant needs for each booth, and they intend to book booths from A to C (inclusive).

outputFormat

Output to standard output (stdout) a single line containing Yes if all participants can be scheduled without any conflicts, or No otherwise.## sample

5 3
3 1 3 5
2 3 4 2
4 2 5 3
No