Taxi drivers and Lyft【数学】

Taxi drivers and Lyft

 CodeForces - 1075B 

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 aiai — 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.

Input

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

The second line contains n+mn+m integers x1,x2,…,xn+mx1,x2,…,xn+m (1≤x1<x2<…<xn+m≤1091≤x1<x2<…<xn+m≤109), where xixi is the coordinate where the ii-th resident lives.

The third line contains n+mn+m integers t1,t2,…,tn+mt1,t2,…,tn+m (0≤ti≤10≤ti≤1). If ti=1ti=1, then the ii-th resident is a taxi driver, otherwise ti=0ti=0.

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

Output

Print mm integers a1,a2,…,ama1,a2,…,am, where aiai 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).

Examples

Input

3 1
1 2 3 10
0 0 1 0

Output

3 

Input

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

Output

2 1 

Input

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

Output

0 0 0 1 

Note

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.

题目大意:第一行输入两个整数n,m,代表有n个人,m辆出租车,第二行输入n+m个数字,分别是人和出租车的位置,第三行有n+m个数字,1代表是出租车,0代表是人,人会选取离他最近的出租车上车,若其离两辆出租车一样近,那么会选取前一辆出租车,问最终每辆出租车能载几人。

解决方法:此题只需遍历一下当前的人离他前一辆以及后一辆车的距离,及时更新即可。

AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
pair<int ,int> p[maxn*3];
int a[maxn];
int num[maxn];
int main() 
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,m;
    cin>>n>>m;
    rep(i,1,n+m) {
    	cin>>p[i].first;
    }
    int an=0;
    rep(i,1,n+m) {
    	cin>>p[i].second;
    	if(p[i].second==1)
    	{
    		a[++an]=p[i].first;
    	}
    }
    int k=1;
    int i;
    for(i=1;i<=n+m;i++) {
    	if(p[i].second==1)
    		break;
    	num[k]++;
    }
    i++;
    for(;i<=n+m;i++)
    {
    	if(p[i].second==1)
    	{
    		k++;
    		continue;
    	}
    	if(k<an) {
	    	if(abs(p[i].first-a[k])<=abs(p[i].first-a[k+1]))
	    		num[k]++;
	    	else
	    		num[k+1]++;
	    }
	    else
	    	num[k]++;
    }
    rep(i,1,an) {
    	cout<<num[i]<<" ";
    }
    cout<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Kaggle Lyft 无人驾驶运动预测是一个基于Lyft无人驾驶数据的竞赛平台,旨在预测无人驾驶汽车动态行为和路径规划。参赛者需要利用Lyft提供的无人驾驶数据集,使用机器学习和深度学习技术来开发出准确的预测模型。 在这个竞赛中,参赛者需要分析Lyft无人驾驶车辆的传感器数据,如摄像头、激光雷达和GPS,以及车辆的行驶历史数据。通过这些数据,参赛者需要构建一个模型来预测车辆的行驶路径、车速、脱离马路和避免碰撞等动态行为。 为了解决这个问题,参赛者可以使用各种机器学习和深度学习的算法,如卷积神经网络、循环神经网络、决策树和支持向量机等。同时,参赛者还可以运用特征工程技术,对数据进行处理和提取有用的特征信息,以提升模型的性能。 参与这个竞赛有助于推动无人驾驶技术的发展,提高自动驾驶汽车的安全性和效率。预测无人驾驶车辆的动态行为可以帮助人们更好地理解无人驾驶汽车的行驶规律,从而为未来的城市交通规划和无人车自动驾驶技术的落地提供参考。 总之,Kaggle Lyft 无人驾驶运动预测是一个有挑战性的竞赛,要求参赛者在无人驾驶数据集上开发准确的动态行为预测模型。这个竞赛对于推动无人驾驶技术的发展具有重要意义,对于提高自动驾驶车辆的安全性和智能性起到了积极的促进作用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值