#abc242g. G - Range Pairing Query
G - Range Pairing Query
Score : points
问题描述
设有 名编号为 的人站成一排。编号为 的人穿着颜色 。
请回答以下格式的 个查询:
- 给定整数 和 ,仅考虑编号为 的人,最多可以形成多少对穿着相同颜色的人?
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
10
1 2 3 2 3 1 3 1 2 3
6
6 10
5 8
3 6
4 4
1 6
1 10
Sample Output 1
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 .
update @ 2024/3/10 10:26:02