#C1005. Counting Robotic Arms Within Given Angle Ranges
Counting Robotic Arms Within Given Angle Ranges
Counting Robotic Arms Within Given Angle Ranges
You are given a set of robotic arms with their initial angles. Each arm's angle is represented as an integer, and it is usually within the range \(0\) to \(360\) degrees. You are also given several queries, where each query provides a range of angles \([L, R]\). For each query, your task is to count the number of robotic arms whose angles lie in the inclusive range \(L \leq \text{angle} \leq R\).
Note: Both the list of angles and the list of queries can be empty. Ensure that your solution handles these edge cases correctly.
inputFormat
The input is read from the standard input (stdin) and follows this format:
- The first line contains an integer (n), representing the number of robotic arms.
- The second line contains (n) space-separated integers, representing the angles of the robotic arms.
- The third line contains an integer (q), representing the number of queries.
- Each of the next (q) lines contains two space-separated integers (L) and (R), describing a query for the range of angles.
outputFormat
For each query, print one integer on a new line—the number of robotic arms with angles within the inclusive range ([L, R]).## sample
5
50 120 180 90 60
3
30 100
100 200
0 360
3
2
5
</p>