knightnemo commited on
Commit
4c3d73e
·
verified ·
1 Parent(s): b489bbb

Upload code_segments/segment_284.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_284.txt +27 -0
code_segments/segment_284.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Impress thy brother, yet fret not thy mother.
2
+
3
+ Robin's brother and mother are visiting, and Robin gets to choose the start day for each visitor.
4
+
5
+ All days are numbered from $1$ to $n$. Visitors stay for $d$ continuous days, all of those $d$ days must be between day $1$ and $n$ inclusive.
6
+
7
+ Robin has a total of $k$ risky 'jobs' planned. The $i$-th job takes place between days $l_i$ and $r_i$ inclusive, for $1 \le i \le k$. If a job takes place on any of the $d$ days, the visit overlaps with this job (the length of overlap is unimportant).
8
+
9
+ Robin wants his brother's visit to overlap with the maximum number of distinct jobs, and his mother's the minimum.
10
+
11
+ Find suitable start days for the visits of Robin's brother and mother. If there are multiple suitable days, choose the earliest one.
12
+
13
+ The first line of the input contains a single integer $t$ ($1\leq t \leq 10^4$) — the number of test cases.
14
+
15
+ The first line of each test case consists of three integers $n$, $d$, $k$ ($1 \le n \le 10^5, 1 \le d, k \le n$) — the number of total days, duration of the visits, and the number of jobs.
16
+
17
+ Then follow $k$ lines of each test case, each with two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le n$) — the start and end day of each job.
18
+
19
+ It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
20
+
21
+ For each test case, output two integers, the best starting days of Robin's brother and mother respectively. Both visits must fit between day $1$ and $n$ inclusive.
22
+
23
+ In the first test case, the only job fills all $2$ days, both should visit on day $1$.
24
+
25
+ In the second test case, day $2$ overlaps with $2$ jobs and day $1$ overlaps with only $1$.
26
+
27
+ In the third test case, Robert visits for days $[1,2]$, Mrs. Hood visits for days $[4,5]$.