CF76B.Mice

提高+/省选-

通过率:0%

时间限制:0.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

现代研究表明,一群饥饿的老鼠在寻找一块奶酪时的行为如下:如果存在多块奶酪,则每只老鼠选择距离自己最近的一块;随后所有老鼠同时向各自选定的奶酪移动。当一只(或若干只)老鼠抵达目标位置且该位置处仍有奶酪时,它们会吃掉这块奶酪并变得饱足;此后再抵达该位置的老鼠则仍保持饥饿状态。所有老鼠的移动速度均相同。

若存在多个“最近奶酪”的选择方案(即某只老鼠到多个奶酪的距离相等),则老鼠将选择一种分配方式,使得最终保持饥饿状态的老鼠数量最少。为验证该理论,科学家决定开展一项实验:他们在笛卡尔平面上放置了 NN 只老鼠和 MM 块奶酪,其中所有老鼠均位于直线 y=Y0y = Y_0 上,所有奶酪均位于另一条直线 y=Y1y = Y_1 上。为分析实验结果,科学家需要一个程序来模拟这群饥饿老鼠的行为。

请编写一个程序,计算最终仍保持饥饿状态(即未获得奶酪)的老鼠的最小数量。

输入格式

The first line of the input contains four integer numbers N (1 ≤ N ≤ 105), M (0 ≤ M ≤ 105), _Y_0 (0 ≤ _Y_0 ≤ 107), _Y_1 (0 ≤ _Y_1 ≤ 107, _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 107 by absolute value.

输入的第一行包含四个整数 NN(1 ≤ N ≤ 1051 \le N \le 10^5)、MM(0 ≤ M ≤ 1050 \le M \le 10^5)、Y0Y_0(0 ≤ Y0 ≤ 1070 \le Y_0 \le 10^7)、Y1Y_1(0 ≤ Y1 ≤ 1070 \le Y_1 \le 10^7,且 Y0 ≠ Y1Y_0 \ne Y_1)。
第二行包含一个严格递增的、长度为 NN 的数列——老鼠的 xx 坐标。
第三行包含一个严格递增的、长度为 MM 的数列——奶酪的 xx 坐标。
所有坐标均为整数,且其绝对值不超过 10710^7。

输出格式

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.

三只老鼠都会选择第一块奶酪。第二只和第三只老鼠将吃掉这块奶酪。第一只老鼠将保持饥饿状态,因为它也跑向了同一块奶酪,但到达得较晚。第二块奶酪将保持未被食用的状态。

输入解题思路,AI测评打分。不知道怎么写?

首页