atcoder#ABC242G. [ABC242G] Range Pairing Query
[ABC242G] Range Pairing Query
Score : points
Problem Statement
people numbered are standing in a row. Person wears Color .
Answer queries of the format below.
- You are given integers and . Considering only Person , how many pairs of people wearing the same color can be formed at most?
Constraints
- All values in input are integers.
- in each query.
Input
Input is given from Standard Input in the following format:
Here, represents the -th query.
Each query is in the following format:
Output
Print lines. The -th line should contain the answer for the -th query as an integer. The use of fast input and output methods is recommended because of potentially large input and output.
10
1 2 3 2 3 1 3 1 2 3
6
6 10
5 8
3 6
4 4
1 6
1 10
2
2
1
0
3
4
We have . This input contains six queries.
The first query is . By pairing Person and paring Person , we can form two pairs of people wearing the same color.
The second query is . By pairing Person and paring Person , we can form two pairs of people wearing the same color.
There can be a query where .