A1219 | [COCI-2011_2012-contest1]#3 PLES
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
There are N boys and N girls at a dance party. We have measured their heights. Each boy will only dance with a girl and each girl will only dance with a boy. Everyone will dance with at most one partner.
Each boy either wants to dance with a girl who is taller than him or with a girl who is shorter than him.
Analogously, each girl either wants to dance with a boy who is taller than her or with a boy who is shorter than her. Boys and girls who are equally tall never want to dance with each other.
Respecting everyone's wishes, determine the maximum number of dancing pairs that can be achieved.
Each boy either wants to dance with a girl who is taller than him or with a girl who is shorter than him.
Analogously, each girl either wants to dance with a boy who is taller than her or with a boy who is shorter than her. Boys and girls who are equally tall never want to dance with each other.
Respecting everyone's wishes, determine the maximum number of dancing pairs that can be achieved.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 100 000).
The second line of input contains N integers whose absolute values are between 1500 and 2500,
inclusive. Their absolute values represent the height of each of the boys in millimetres. Positive height values indicate boys who want to dance with girls taller than themselves, while negative height values indicate boys who want to dance with girls shorter than themselves.
The third line of input contains N integers whose absolute values are between 1500 and 2500, inclusive.
Their absolute values represent the height of each of the girls in millimetres. Positive height values indicate girls who want to dance with boys taller than themselves, while negative height values indicate girls who want to dance with boys shorter than themselves.
The second line of input contains N integers whose absolute values are between 1500 and 2500,
inclusive. Their absolute values represent the height of each of the boys in millimetres. Positive height values indicate boys who want to dance with girls taller than themselves, while negative height values indicate boys who want to dance with girls shorter than themselves.
The third line of input contains N integers whose absolute values are between 1500 and 2500, inclusive.
Their absolute values represent the height of each of the girls in millimetres. Positive height values indicate girls who want to dance with boys taller than themselves, while negative height values indicate girls who want to dance with boys shorter than themselves.
输出格式
The only line of output must contain the maximum number of dancing pairs.
输入输出样例
输入 #1
1 -1800 1800
输出 #1
0
输入 #2
1 1700 -1800
输出 #2
1
输入 #3
2 -1800 -2200 1900 1700
输出 #3
2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted