Number of pairs - MarisaOJ: Marisa Online Judge

Number of pairs

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ distinct integers in ascending order. Find the number of pairs $i < j$ such that $A_i + A_j = x$. ### Input - The first line contains two integers $n, x$. - The second line contains $n$ integers $A_i$. ### Output - Print the number of pairs $(i, j)$. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i, x \le 10^9$. ### Example Input: ``` 5 6 1 2 3 4 5 ``` Output: ``` 2 ```