305685: CF1075B. Taxi drivers and Lyft

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Taxi drivers and Lyft

题意翻译

【题面】 在一个数轴上有 $m$ 个司机和 $n$ 个乘客 每当一个乘客叫车时,距离他最近的司机会前往他所在处,如果有多个同样的最短距离的司机,坐标最小的会前往他所在处 你需要求出 $a_i$ ,表示有多少乘客(假设他最早叫车)会叫坐标第 $i$ 小的司机 司机不能叫车 【输入】 第一行两个整数 $n,m(1\le n,m\le 10^5)$,表示乘客和司机数量 第二行 $n+m$ 个整数 $x_1,x_2,\dots,x_{n+m}$,表示第 $i$ 个人的坐标 第三行 $n+m$ 个整数 $t_1,t_2,\dots,t_{n+m}$ 若 $t_i$ 为 $0$ 则第 $i$ 个人为乘客,否则为司机 【输出】 一行 $m$ 个整数,$a_1,a_2,\dots,a_n$

题目描述

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 $ m $ taxi drivers in the city, who every day transport the rest of the city residents — $ n $ 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 $ i $ the number $ a_{i} $ — the number of riders that would call the $ i $ -th taxi driver when all drivers and riders are at their home? The taxi driver can neither transport himself nor other taxi drivers.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ ( $ 1 \le n,m \le 10^5 $ ) — number of riders and taxi drivers. The second line contains $ n + m $ integers $ x_1, x_2, \ldots, x_{n+m} $ ( $ 1 \le x_1 < x_2 < \ldots < x_{n+m} \le 10^9 $ ), where $ x_i $ is the coordinate where the $ i $ -th resident lives. The third line contains $ n + m $ integers $ t_1, t_2, \ldots, t_{n+m} $ ( $ 0 \le t_i \le 1 $ ). If $ t_i = 1 $ , then the $ i $ -th resident is a taxi driver, otherwise $ t_i = 0 $ . It is guaranteed that the number of $ i $ such that $ t_i = 1 $ is equal to $ m $ .

输出格式


Print $ m $ integers $ a_1, a_2, \ldots, a_{m} $ , where $ a_i $ is the answer for the $ i $ -th taxi driver. The taxi driver has the number $ i $ if among all the taxi drivers he lives in the $ i $ -th smallest coordinate (see examples for better understanding).

输入输出样例

输入样例 #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 $ n $ riders will go to him. In the second example, the first taxi driver lives at the point with the coordinate $ 2 $ , and the second one lives at the point with the coordinate $ 6 $ . Obviously, the nearest taxi driver to the rider who lives on the $ 3 $ coordinate is the first one, and to the rider who lives on the coordinate $ 5 $ is the second one. The rider who lives on the $ 4 $ 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.

Input

题意翻译

【题面】 在一个数轴上有 $m$ 个司机和 $n$ 个乘客 每当一个乘客叫车时,距离他最近的司机会前往他所在处,如果有多个同样的最短距离的司机,坐标最小的会前往他所在处 你需要求出 $a_i$ ,表示有多少乘客(假设他最早叫车)会叫坐标第 $i$ 小的司机 司机不能叫车 【输入】 第一行两个整数 $n,m(1\le n,m\le 10^5)$,表示乘客和司机数量 第二行 $n+m$ 个整数 $x_1,x_2,\dots,x_{n+m}$,表示第 $i$ 个人的坐标 第三行 $n+m$ 个整数 $t_1,t_2,\dots,t_{n+m}$ 若 $t_i$ 为 $0$ 则第 $i$ 个人为乘客,否则为司机 【输出】 一行 $m$ 个整数,$a_1,a_2,\dots,a_n$

加入题单

上一题 下一题 算法标签: