#abc355d. D - Intersecting Intervals
D - Intersecting Intervals
Score : points
问题陈述
给定 个实数区间。第 个 区间是 。找出满足第 个和第 个区间相交的 对的数量,其中 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given intervals of real numbers. The -th interval is . Find the number of pairs such that the -th and -th intervals intersect.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 5
7 8
3 7
Sample Output 1
2
The given intervals are . Among these, the -st and -rd intervals intersect, as well as the -nd and -rd intervals, so the answer is .
Sample Input 2
3
3 4
2 5
1 6
Sample Output 2
3
Sample Input 3
2
1 2
3 4
Sample Output 3
0