| ICPC Masters Mexico 2026 |
|---|
| Закончено |
Registration has closed with $$$N$$$ former contestants signed up as individuals, and the contest is played in teams of two. The organizers have to put them into pairs.
Every participant has a rating. The registration system stores it as the difference from a fixed baseline, so the rating $$$a_i$$$ of participant $$$i$$$ is an integer that can also be negative, for somebody who has not written code in a contest for many years.
Every pair must hold exactly two different participants, and each participant may belong to at most one pair. The participants who are left over help as volunteers instead. A pair is competitive if the sum of the ratings of its two members is at least $$$X$$$.
A participant who cannot be placed in a competitive pair simply stays unpaired. Find the maximum possible number of competitive pairs.
The first line contains two integers $$$N$$$ and $$$X$$$ ($$$1 \le N \le 2 \cdot 10^5$$$, $$$-10^9 \le X \le 10^9$$$) — the number of participants and the required total rating.
The second line contains $$$N$$$ integers $$$a_1,a_2,\ldots,a_N$$$ ($$$-10^9 \le a_i \le 10^9$$$) — the participants' ratings.
Print one integer — the maximum possible number of competitive pairs.
5 104 6 3 7 8
2
6 1001 2 3 4 5 6
0
7 -2-10 -1 -1 0 3 3 8
3
In the first example, participants with ratings $$$3$$$ and $$$8$$$ can form one pair, and participants with ratings $$$4$$$ and $$$7$$$ can form another.
In the third example, the pairs $$$(-10,8)$$$, $$$(-1,3)$$$, and $$$(-1,3)$$$ are all competitive.
| Название |
|---|


