#P7764. [COCI 2016/2017 #5] Poklon
[COCI 2016/2017 #5] Poklon
Description
You are given an array containing natural numbers.
Then you need to answer queries. For each query, output the number of natural numbers that appear exactly twice in the interval .
Input Format
The first line contains two integers , representing the number of elements in the array and the number of queries.
The second line contains integers, representing the elements in the array.
The next lines each contain two integers , representing the query interval.
Output Format
Output lines. Each line corresponds to the answer for one query.
5 1
1 2 1 1 1
1 3
1
5 2
1 1 1 1 1
2 4
2 3
0
1
5 2
1 1 2 2 3
1 1
1 5
0
2
Hint
[Sample 1 Explanation]
In the interval , only appears exactly twice.
[Constraints]
For of the testdata, .
For of the testdata, , , and all elements in the array are natural numbers less than .
[Hints and Notes]
This problem is translated from COCI 2016-2017 CONTEST #5 T5 Poklon.
The score of this problem follows the original COCI setting, with a full score of .
Translated by ChatGPT 5
京公网安备 11011102002149号