#abc377d. D - Many Segments 2
D - Many Segments 2
Score : points
问题陈述
给定两个长度为 的正整数序列 和 ,以及一个整数 。
找出满足以下两个条件的整数对 的数量:
- 对于每一个 ,区间 没有完全包含区间 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given two sequences of positive integers of length , and , and an integer .
Find the number of pairs of integers that satisfy both of the following conditions:
- For every , the interval does not completely contain the interval .
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
2 4
1 2
3 4
Sample Output 1
5
The five pairs satisfy the conditions.
For example, does not satisfy the conditions because the interval completely contains the interval .
Sample Input 2
6 5
1 1
2 2
3 3
4 4
5 5
1 5
Sample Output 2
0
There may be cases where no pairs of integers satisfy the conditions.
Sample Input 3
6 20
8 12
14 20
11 13
5 19
4 11
1 6
Sample Output 3
102