JPMorgan ChaseOA #9
Signal Filter
Estimated EasyJudge-ready
Topics (AI-labelled)Prefix & Ranges
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.
Input
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
Output a single integer answer.
Example 1
Input:
5 3
10 13 15 16 17
10 17
13 15
13 17
Output:
2
Example 2
Input:
3 1
1 1 2
1 1
Output:
2
Example 3
Input:
2 1
1 2
3 4
Output:
0
Example notes
The outputs of the three public examples are, in order: 2; 2; 0. These answers have been checked by independent enumeration or direct simulation.
Editorial
Loading solution…