Hayden traveled to France with his friend Matt and Sunny. They bought a long baguette with length $N$ units, which could be seen as lying on a number line from position $0$ to position $N$.
However, Matt and Sunny have terrible taste.
Matt loves wasabi. He spreads wasabi from position $A$ to position $B$.
Sunny loves peanut butter. He spreads peanut butter from position $C$ to position $D$.
Hayden hates both wasabi and peanut butter. He is very hungry and wants to eat a single continuous piece of baguette with neither wasabi nor peanut butter on it, with at least $K$ units. Determine whether Hayden can find such a piece.
Input
The first line contains two integers $N$ and $K$ ($1 \leq K \leq N \leq 10^9$).
The second line contains four integers $A, B, C, D$ ($0 \leq A \lt B \leq N$ and $0 \leq C \lt D \leq N$).
Output
Print "Yes" if Hayden can eat a single continuous piece of baguette with neither wasabi nor peanut butter on it with at least $K$ units.
Otherwise, print "No".
Subtasks
Subtask 1 (5 pts): $A = C$ and $B = D$.
Subtask 2 (10 pts): $A \lt C$ and $B \gt D$.
Subtask 3 (15 pts): $B \leq C$.
Subtask 4 (20 pts): $B \gt C$
Subtask 5 (20 pts): $N \leq 1000$.
Subtask 6 (30 pts): No additional constraints.
Sample Test Cases
| Input | Output | |
|---|---|---|
| 10 3 1 5 7 9 |
No | |
In the first sample, the baguette has length $N=10$.
0 1 5 7 9 10
|--------|////////////////////////////////|----------------|////////////////|--------|
OK Wasabi OK Peanut Butter OK
(1 unit) (4 units) (2 units) (2 units) (1 unit)
|
||
| 10 3 1 5 4 7 |
Yes | |
Scoring: Per Subtask
Authored by wy24180
Appeared in WYHK 2026 Mini Comp 0 🗣️🙊🇫🇷🥖🤮 🟥🟦3️⃣2️⃣1️⃣🎊 8️⃣0️⃣🧙♀️ 🇩🇪🏙️🌍🦠🧑💻💃🌧️