Rare Antiques
Practice Questions
Rare Antiques
Problem Statement
Berlin is in an auction lot where there are antiques with different ID's, in the black market antiques are sold in pair and a pair of antiques are considered rare if their sum of ID is x. Berlin need a total number of rare antiques so that he can plan accordingly.
Boundary Condition(s)
1 <= t <= 10⁵
1 <= n <= 10⁵
0 <= a[i] <= x <= 10⁵
Input Format
First line represents the number of test cases.
Second line represents the number of antiques and x in line.
Third line represents the input array with distinct element.
Output Format
Number of rare antiques.
Example Input/Output 1
Input
1
5 5
1 3 2 4 7
Output
4
Explanation
The antique ID's are given as 1, 3, 2, 4, 7 and the sum necessary, x is 5.
Then the pairs satisfying the conditions will be 1-4, 2-3. Hence, in total 4 antiques are rare.
Comments