A8124 | Mice
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Modern researches has shown that a flock of hungry mice searching for a piece of cheese acts as follows: if there are several pieces of cheese then each mouse chooses the closest one. After that all mice start moving towards the chosen piece of cheese. When a mouse or several mice achieve the destination point and there is still a piece of cheese in it, they eat it and become well-fed. Each mice that reaches this point after that remains hungry. Moving speeds of all mice are equal.
If there are several ways to choose closest pieces then mice will choose it in a way that would minimize the number of hungry mice. To check this theory scientists decided to conduct an experiment. They located $N$ mice and $M$ pieces of cheese on a cartesian plane where all mice are located on the line $y=Y_{0}$ and all pieces of cheese — on another line $y=Y_{1}$ . To check the results of the experiment the scientists need a program which simulates the behavior of a flock of hungry mice.
Write a program that computes the minimal number of mice which will remain hungry, i.e. without cheese.
If there are several ways to choose closest pieces then mice will choose it in a way that would minimize the number of hungry mice. To check this theory scientists decided to conduct an experiment. They located $N$ mice and $M$ pieces of cheese on a cartesian plane where all mice are located on the line $y=Y_{0}$ and all pieces of cheese — on another line $y=Y_{1}$ . To check the results of the experiment the scientists need a program which simulates the behavior of a flock of hungry mice.
Write a program that computes the minimal number of mice which will remain hungry, i.e. without cheese.
输入格式
The first line of the input contains four integer numbers $N$ ( $1<=N<=10^{5}$ ), $M$ ( $0<=M<=10^{5}$ ), $Y_{0}$ ( $0<=Y_{0}<=10^{7}$ ), $Y_{1}$ ( $0<=Y_{1}<=10^{7}$ , $Y_{0}≠Y_{1}$ ). The second line contains a strictly increasing sequence of $N$ numbers — $x$ coordinates of mice. Third line contains a strictly increasing sequence of $M$ numbers — $x$ coordinates of cheese. All coordinates are integers and do not exceed $10^{7}$ by absolute value.
输出格式
The only line of output should contain one number — the minimal number of mice which will remain without cheese.
输入输出样例
输入 #1
3 2 0 2 0 1 3 2 5
输出 #1
1
All the three mice will choose the first piece of cheese. Second and third mice will eat this piece. The first one will remain hungry, because it was running towards the same piece, but it was late. The second piece of cheese will remain uneaten.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted