2020-2021 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules) |
---|
Finished |
Consider a long corridor which can be divided into $$$n$$$ square cells of size $$$1 \times 1$$$. These cells are numbered from $$$1$$$ to $$$n$$$ from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in the $$$a$$$-th cell, the guard is in the $$$b$$$-th cell ($$$a \ne b$$$).
There are $$$m$$$ firecrackers in the hooligan's pocket, the $$$i$$$-th firecracker explodes in $$$s_i$$$ seconds after being lit.
The following events happen each second (sequentially, exactly in the following order):
Obviously, the hooligan will be caught sooner or later, since the corridor is finite. His goal is to see the maximum number of firecrackers explode before he is caught; that is, he will act in order to maximize the number of firecrackers that explodes before he is caught.
Your task is to calculate the number of such firecrackers, if the hooligan acts optimally.
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases.
Each test case consists of two lines. The first line contains four integers $$$n$$$, $$$m$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 10^9$$$; $$$1 \le m \le 2 \cdot 10^5$$$; $$$1 \le a, b \le n$$$; $$$a \ne b$$$) — the size of the corridor, the number of firecrackers, the initial location of the hooligan and the initial location of the guard, respectively.
The second line contains $$$m$$$ integers $$$s_1$$$, $$$s_2$$$, ..., $$$s_m$$$ ($$$1 \le s_i \le 10^9$$$), where $$$s_i$$$ is the time it takes the $$$i$$$-th firecracker to explode after it is lit.
It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print one integer — the maximum number of firecrackers that the hooligan can explode before he is caught.
3 7 2 3 6 1 4 7 2 3 6 5 1 7 2 3 6 4 4
2 1 1
In the first test case, the hooligan should act, for example, as follows:
Name |
---|