❌Fast Search (Contest)

Fast Search (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB

Problem Statement :

You are given an array a of n integers a1, a2,... , an. Your task is to response to the queries like : How many number's values are between l and r ? Input The first line of the input contains a single space separated integer n denoting the length of the array. The second line of the input contains n space separated integers denoting an array a. The third line of the input contains a single space separated integer k denoting the number of queries. The following k lines contain a pair of integers l and r - query, described above.

Constraints 1 ≀ N ≀ 105 -109 ≀ a[i] ≀ 109 1 ≀ k ≀ 105 -109 ≀ l ≀ r ≀ 109 Output The output must consist of k integers - responses for the queries. Example Sample Input 5 10 1 10 3 4 4 1 10 2 9 3 4 2 2 Sample Output 5 2 2 0

link:https://my.newtonschool.co/playground/code/zotw1gpda3bi/

Last updated