knightnemo commited on
Commit
89e6a51
·
verified ·
1 Parent(s): 628f637

Upload code_segments/segment_202.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_202.txt +24 -0
code_segments/segment_202.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ As a computer science student, Alex faces a hard challenge — showering. He tries to shower daily, but despite his best efforts there are always challenges. He takes $s$ minutes to shower and a day only has $m$ minutes!
2
+
3
+ He already has $n$ tasks planned for the day. Task $i$ is represented as an interval $(l_i$, $r_i)$, which means that Alex is busy and can not take a shower in that time interval (at any point in time strictly between $l_i$ and $r_i$). No two tasks overlap.
4
+
5
+ Given all $n$ time intervals, will Alex be able to shower that day? In other words, will Alex have a free time interval of length at least $s$?
6
+
7
+ ![](CDN_BASE_URL/5d5195053b99e5c6936ccefadc239679)
8
+
9
+ In the first test case, Alex can shower for the first $3$ minutes of the day and not miss any of the tasks.
10
+
11
+ The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
12
+
13
+ The first line of each test case contains three integers $n$, $s$, and $m$ ($1 \leq n \leq 2 \cdot 10^5$; $1 \leq s, m \leq 10^9$) — the number of time intervals Alex already has planned, the amount of time Alex takes to take a shower, and the amount of minutes a day has.
14
+
15
+ Then $n$ lines follow, the $i$-th of which contains two integers $l_i$ and $r_i$ ($0 \leq l_i < r_i \leq m$) — the time interval of the $i$-th task. No two tasks overlap.
16
+
17
+ Additional constraint on the input: $l_i > r_{i-1}$ for every $i > 1$.
18
+
19
+ The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
20
+
21
+ For each test case output "YES" (without quotes) if Alex can take a shower for that given test case, and "NO" (also without quotes) otherwise.
22
+
23
+ You can output "YES" and "NO" in any case (for example, strings "yEs", "yes", and "Yes" will be recognized as a positive response).
24
+