cswork / OA打开练习工作台

JPMorgan ChaseOA #9

Signal Filter

估计简单可在线判题

考点(AI 标注)前缀和区间

Each closed-interval filter lets through only frequencies inside its interval. Find the number of input signals that pass every filter; repeated frequencies count as separate signals. All filters are guaranteed to share a common range.

输入格式

The first line contains n m, the second line contains n frequencies, followed by m lines of lower upper; 1≤n,m≤100000, and frequencies and endpoints are in 1..1000000000.

输出格式

Output a single integer answer.

样例 1

输入:

5 3
10 13 15 16 17
10 17
13 15
13 17

输出:

2

样例 2

输入:

3 1
1 1 2
1 1

输出:

2

样例 3

输入:

2 1
1 2
3 4

输出:

0

样例说明

The outputs of the three public examples are, in order: 2; 2; 0. These answers have been checked by independent enumeration or direct simulation.