CF1075B.Taxi drivers and Lyft
普及/提高-
通过率:0%
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 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 ai — 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≤n,m≤105 ) — number of riders and taxi drivers.
The second line contains n+m integers x1,x2,…,xn+m ( 1≤x1<x2<…<xn+m≤109 ), where xi is the coordinate where the i -th resident lives.
The third line contains n+m integers t1,t2,…,tn+m ( 0≤ti≤1 ). If ti=1 , then the i -th resident is a taxi driver, otherwise ti=0 .
It is guaranteed that the number of i such that ti=1 is equal to m .
输出格式
Print m integers a1,a2,…,am , where ai 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.