Cupid of Love
InterviewTime limit1sMemory limit512 MB
Given heights and height thresholds for female and male students, find the maximum number of pairs where each partner prefers the other.
Problem
Bosun came to Jinju for an outing and was so thirsty that he walked into a cafe in front of Gyeongsang National University. At that cafe, female students from Jinju National University of Education and male students from Yeonam College of Engineering were holding a group meeting.
This meeting has one curious fact. Each student's preference toward a partner depends on only one factor, height. Specifically, a female student prefers only male students shorter than her preference threshold. A male student prefers only female students taller than his preference threshold.
Jaehyeok, a self-proclaimed love cupid, was also in the cafe. He listened closely to the conversations at the meeting tables and learned the preference threshold of every student. Hoping that many couples would form, he decided to pair the students himself.
Watching all of this, Bosun wondered about the maximum number of couples that could form at this meeting. In this problem, a couple is a set of one female student and one male student who prefer each other, and no student can belong to more than one couple.
Input
The first line contains the number of female students and the number of male students , separated by a space. ()
The second line contains , separated by spaces. is the height of the -th female student. ()
The third line contains , separated by spaces. is the height of the -th male student. ()
The fourth line contains , separated by spaces. is the preference threshold of the -th female student. ()
The fifth line contains , separated by spaces. is the preference threshold of the -th male student. ()
All numbers in the input are integers.
Output
On the first line, print the maximum number of couples that can form at the meeting.