You have arranged balloons in a linear order. Every balloon is colored and the
The number
You are provided with some specific ranges and your task is to determine the number of colors that get repeated for exactly
Input format
- First line: Three integers
, , and ( ). Here, is the number of balloons, is the inappropriate number, and is the number of queries. - Second line: Contains
integers depicting the color of balloons ( ) - Each
lines: Contains two integers and (\(0\le l,\ r)
Output format
Print the number of colors that are repeated exactly k times. If the answer to the previous query is
.
5 2 3 1 2 1 3 3 0 4 0 3 2 0
2 1 0
In the first query 0,4 is the range so the numbers in this range are 1,2,1,3,3 ,so 1 and 3 are used exactly 2 time.(because it’s the first query ans=0)
(ans+l)%n=(0+0)%5=0
(ans+r)%n=(0+4)%5=4
In the second query 0,2 is the range so the numbers in this range are 1,2,1 ,so 1 is used exactly 2 time.
(ans+l)%n=(2+0)%5=2
(ans+r)%n=(2+3)%5=0
In the third query 1,3 is the range so the numbers in this range are 2,1,3 so none of them are used exactly 2 time.
(ans+l)%n=(1+2)%5=3
(ans+r)%n=(1+0)%5=1
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor