P29666 [洛谷] [COCI2011-2012#1] Dance Party
提高-
题目描述

Problem Description

At a dance party, there are $N$ boys and $N$ girls, and we know their heights. It is stipulated that each person can dance with at most one partner.

Each boy either wants to dance with a girl taller than him or a girl shorter than him. Similarly, each girl either wants to dance with a boy taller than her or a boy shorter than her. There are no boys and girls of the same height who want to dance with each other.

Determine the maximum number of pairs of dance partners if everyone's wishes are followed.

Input Format

The first line of input contains a positive integer $N$.

The next $N$ lines each contain an integer $A_i$. The absolute value of $A_i$ represents the height of the $i$-th boy. If $A_i$ is positive, it means the $i$-th boy wants to dance with a girl taller than him; if $A_i$ is negative, it means the $i$-th boy wants to dance with a girl shorter than him.

The next $N$ lines each contain an integer $B_j$. The absolute value of $B_j$ represents the height of the $j$-th girl. If $B_j$ is positive, it means the $j$-th girl wants to dance with a boy taller than her; if $B_j$ is negative, it means the $j$-th girl wants to dance with a boy shorter than her.

Output Format

Output a single integer on one line, representing the maximum number of pairs of dance partners.

Sample Input and Output

Sample Input #1

1
-1800
1800

Sample Output #1

0

Sample Input #2

1
1700
-1800

Sample Output #2

1

Sample Input #3

2
-1800 -2200
1900 1700

Sample Output #3

2

Notes

Data Range

For $100\%$ of the data, $1 \le N \le 10^5$, $1500 \le |A_i, B_j| \le 2500$.

Explanation

This problem is scored according to the original COCI settings, with a full score of $110$.

The problem is translated from COCI2011-2012 CONTEST #1 T4 PLES.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 -1800 1800
样例输出
0