WBC '25 P2 - Student IDs
View as PDFWelcome Back Contest: 2025 Problem 2
Every student in the school board has their own unique student ID based on when they joined the school board. Mr. Quinn wonders how many students in his class of students joined during certain periods of time. More specifically, he asks
questions of the form
How many students in my class have student IDs between
and
inclusive?
Since Mr. Quinn is too busy marking, he needs your help to answer these questions!
Input Specification
The first line contains the integers and
, separated by a single space.
The next line contains spaced integers
, representing the unique IDs of the students in the class.
The next lines contain two spaced integers,
and
, representing a question to be answered.
Output Specification
For each question, output the answer on its own line.
Subtasks
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
No additional constraints
Sample Input 1
5 3
2 5 1 8 6
1 3
2 7
6 6
Output for Sample Input 1
2
3
1
Explanation of Output for Sample Input 1
For the first question, there are student IDs between
and
inclusive (
and
).
For the second question, there are student IDs between
and
inclusive (
,
and
).
For the third question, there are student IDs between
and
inclusive (just
).
Sample Input 2
7 3
46 23 91 15 67 24 50
1 100
16 22
20 50
Output for Sample Input 2
7
0
4
Comments