CF1075B.Taxi drivers and Lyft

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.

Lyft has become so popular so that it is now used by all mm taxi drivers in the city, who every day transport the rest of the city residents — nn riders.

Each resident (including taxi drivers) of Palo-Alto lives in its unique location (there is no such pair of residents that their coordinates are the same).

The Lyft system is very clever: when a rider calls a taxi, his call does not go to all taxi drivers, but only to the one that is the closest to that person. If there are multiple ones with the same distance, then to taxi driver with a smaller coordinate is selected.

But one morning the taxi drivers wondered: how many riders are there that would call the given taxi driver if they were the first to order a taxi on that day? In other words, you need to find for each taxi driver ii the number aia_{i} — the number of riders that would call the ii-th taxi driver when all drivers and riders are at their home?

The taxi driver can neither transport himself nor other taxi drivers.

帕洛阿尔托是一座不寻常的城市,因为它是一条无限延伸的数轴。这座城市还以 Lyft Level 5 办公室而闻名。

Lyft 如此受欢迎,以至于如今城市中全部 mm 名出租车司机每天都使用它来运送其余的 nn 名乘客。

每位居民(包括出租车司机)都居住在帕洛阿尔托独一无二的位置上(不存在任意两位居民坐标相同的情况)。

Lyft 系统非常智能:当一名乘客呼叫出租车时,该呼叫并不会发送给所有出租车司机,而只会发送给距离该乘客最近的一位司机。若存在多名司机与该乘客距离相同,则选择坐标更小的那位司机。

但某天清晨,出租车司机们忽然好奇:如果当天第一位叫车的乘客恰好是某位特定乘客,那么会有多少名乘客会呼叫这位特定的出租车司机?换言之,你需要对每位出租车司机 ii,求出数值 aia_{i} —— 即当所有司机和乘客均位于各自住所时,会呼叫第 ii 位出租车司机的乘客人数。

出租车司机既不能运送自己,也不能运送其他出租车司机。

输入格式

The first line contains two integers nn and mm (1≤n,m≤1051 \le n,m \le 10^5) — number of riders and taxi drivers.

The second line contains n+mn + m integers x1,x2,…,xn+mx_1, x_2, \ldots, x_{n+m} (1≤x1<x2<…<xn+m≤1091 \le x_1 \lt x_2 \lt \ldots \lt x_{n+m} \le 10^9), where xix_i is the coordinate where the ii-th resident lives.

The third line contains n+mn + m integers t1,t2,…,tn+mt_1, t_2, \ldots, t_{n+m} (0≤ti≤10 \le t_i \le 1). If ti=1t_i = 1, then the ii-th resident is a taxi driver, otherwise ti=0t_i = 0.

It is guaranteed that the number of ii such that ti=1t_i = 1 is equal to mm.

第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \le n,m \le 10^5),分别表示乘客人数和出租车司机人数。

第二行包含 n+mn + m 个整数 x1,x2,…,xn+mx_1, x_2, \ldots, x_{n+m}(1≤x1<x2<…<xn+m≤1091 \le x_1 \lt x_2 \lt \ldots \lt x_{n+m} \le 10^9),其中 xix_i 表示第 ii 位居民的居住坐标。

第三行包含 n+mn + m 个整数 t1,t2,…,tn+mt_1, t_2, \ldots, t_{n+m}(0≤ti≤10 \le t_i \le 1)。若 ti=1t_i = 1,则第 ii 位居民是出租车司机;否则 ti=0t_i = 0。

保证满足 ti=1t_i = 1 的 ii 的个数恰好为 mm。

输出格式

Print mm integers a1,a2,…,ama_1, a_2, \ldots, a_{m}, where aia_i is the answer for the ii-th taxi driver. The taxi driver has the number ii if among all the taxi drivers he lives in the ii-th smallest coordinate (see examples for better understanding).

输出 mm 个整数 a1,a2,…,ama_1, a_2, \ldots, a_{m},其中 aia_i 表示第 ii 位出租车司机的答案。若所有出租车司机按其居住坐标从小到大排序后,某位司机位于第 ii 小的位置,则该司机编号为 ii(参见示例以更好地理解)。

输入输出样例

  • 输入#1

    3 1
    1 2 3 10
    0 0 1 0

    输出#1

    3
  • 输入#2

    3 2
    2 3 4 5 6
    1 0 0 0 1

    输出#2

    2 1
  • 输入#3

    1 4
    2 4 6 10 15
    1 1 1 1 0

    输出#3

    0 0 0 1

说明/提示

In the first example, we have only one taxi driver, which means an order from any of nn riders will go to him.

In the second example, the first taxi driver lives at the point with the coordinate 22, and the second one lives at the point with the coordinate 66. Obviously, the nearest taxi driver to the rider who lives on the 33 coordinate is the first one, and to the rider who lives on the coordinate 55 is the second one. The rider who lives on the 44 coordinate has the same distance to the first and the second taxi drivers, but since the first taxi driver has a smaller coordinate, the call from this rider will go to the first taxi driver.

In the third example, we have one rider and the taxi driver nearest to him is the fourth one.

在第一个例子中,我们只有一名出租车司机,这意味着任意一名 nn 名乘客的订单都会分配给他。

在第二个例子中,第一名出租车司机住在坐标为 22 的位置,第二名出租车司机住在坐标为 66 的位置。显然,住在坐标 33 的乘客距离第一名司机最近,而住在坐标 55 的乘客距离第二名司机最近。住在坐标 44 的乘客到第一名和第二名司机的距离相等,但由于第一名司机的坐标更小,因此该乘客的呼叫将分配给第一名司机。

在第三个例子中,我们只有一名乘客,离他最近的出租车司机是第四名。

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

首页