report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
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 ```
Introduction to Binary Search
Binary search
Binary search 2
Binary search 3
Large subarray
Count query
Counting pairs
The k-th candy
Triangle edges
Hamming number
Consecutive integers
Gnimmah distance
Subarray
Topic
Binary search
Rating 800
Solution (1) Solution