#3236. Intersection

0
    ID: 3236 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc199BGESP 2级枚举(单层循环)

Intersection

Intersection

题目描述

You are given sequences of length NN each: A=(A1,A2,A3,…,AN)A = (A_1, A_2, A_3, \dots, A_N) and B=(B1,B2,B3,…,BN)B = (B_1, B_2, B_3, \dots, B_N).
Find the number of integers xx satisfying the following condition:

Ai≤x≤BiA_i \le x \le B_i holds for every integer ii such that 1≤i≤N1 \le i \le N.

输入格式

Input is given from Standard Input in the following format: NN A1A_1 A2A_2 A3A_3 …\dots ANA_N B1B_1 B2B_2 B3B_3 …\dots BNB_N

输出格式

Print the answer.

2
3 2
7 5
3
3
1 5 3
10 7 3
0
3
3 2 5
6 9 8
2

提示

1≤N≤1001 \le N \le 100 1≤Ai≤Bi≤10001 \le A_i \le B_i \le 1000 All values in input are integers.xx must satisfy both 3≤x≤73 \le x \le 7 and 2≤x≤52 \le x \le 5.
There are three such integers: 33, 44, and 55.
There may be no integer xx satisfying the condition.

标签: AtCoder|abc199B

来源

AtCoder|abc199B