Codeforces Round 904 (Div. 2) |
---|
Finished |
The array $$$a_1, a_2, \ldots, a_m$$$ is initially filled with zeroes. You are given $$$n$$$ pairwise distinct segments $$$1 \le l_i \le r_i \le m$$$. You have to select an arbitrary subset of these segments (in particular, you may select an empty set). Next, you do the following:
Please, find the maximum cost among all subsets of segments.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of segments and the length of the array.
The following $$$n$$$ lines of each test case describe the segments. The $$$i$$$-th of these lines contains two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le m$$$). It is guaranteed that the segments are pairwise distinct.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the maximum cost among all subsets of the given set of segments.
61 32 23 82 43 54 66 31 11 21 32 22 33 37 62 21 61 25 61 54 43 66 276 265 172 320 211 2212 244 10000000002 9999999993 1000000000123456789 9876543219274 123456789
1 3 2 3 4 4
In the first test case, there is only one segment available. If we do not select it, then the array will be $$$a = [0, 0, 0]$$$, and the cost of such (empty) subset of segments will be $$$0$$$. If, however, we select the only segment, the array will be $$$a = [0, 1, 0]$$$, and the cost will be $$$1 - 0 = 1$$$.
In the second test case, we can select all the segments: the array will be $$$a = [0, 1, 2, 3, 2, 1, 0, 0]$$$ in this case. The cost will be $$$3 - 0 = 3$$$.
Name |
---|