Age Demographic

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Java 2.0s
Python 1.5s
Memory limit: 256M

Author:
Problem type

You have just uploaded your first video as a content creator.

Curious about which audiences you should be targeting, you have gathered data about N (1N3105) different viewers. Specifically, you know the ages xi (1xi109) of every single person that has watched your video.

Given Q (1Q3105) different queries, how many people between the ages of a and b inclusive (1a,b109) have watched your video?

Input Specification

The first line of input contains an integer N.

The second line of input contains N space-separated integers xi.

The third line of input contains an integer Q.

The next Q lines of input each contain 2 space-separated integers a and b (ab).

Output Specification

For each query, output the total number of viewers between the ages of a and b inclusive.

Sample Input

Copy
8
12 8 7 12 14 15 9 28
5
6 12
3 5
13 18
3 20
28 28

Sample Output

Copy
5
0
2
7
1

Comments


  • 3
    Viv_CCGS  commented on Nov. 17, 2024, 11:06 p.m. edited

    1 billion years old and watching the same videos as a 1 year old...