Counting pairs - MarisaOJ: Marisa Online Judge

Counting pairs

Time limit: 1000 ms
Memory limit: 256 MB
Given an array an array $A$ of $n$ positive integers. Count the number of pairs $(i, j)$ and $i < j$ that $l \le A_i + A_j \le r$. ### Input - The first line contains 3 integers $n, l, r$. - The second line contains $n$ integers $A_i$. ### Output - Print an integers is the number of pairs $(i, j)$ and $i < j$ that $l \le A_i + A_j \le r$. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i, l, r \le 10^9$. ### Example Input: ``` 3 2 4 1 2 3 ``` Output: ``` 2 ```