http://codeforces.com/contest/1075/problem/B

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

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

Copy
3 1
1 2 3 10
0 0 1 0
output

Copy
3 
input

Copy
3 2
2 3 4 5 6
1 0 0 0 1
output

Copy
2 1 
input

Copy
1 4
2 4 6 10 15
1 1 1 1 0
output

Copy
0 0 0 1 

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 300010;
int n, m;
long long pos[maxn], dir[maxn];
int cnt1 = 0, cnt = 0; struct Node{
long long dis;
long long num;
}car[maxn]; int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= m + n; i ++)
cin >> pos[i];
for(int i = 1; i <= n + m; i ++) {
cin >> dir[i];
if(dir[i] == 1) {
cnt1 ++;
car[cnt1].dis = pos[i];
}
} for(int i = 1; i <= n + m; i ++) {
if(m == 1) {
printf("%d\n", n + m - 1);
return 0;
}
if(pos[i] < car[1].dis)
car[1].num ++;
else if(pos[i] > car[cnt1].dis)
car[cnt1].num = car[cnt1].num + 1; else if(dir[i] == 1)
cnt ++;
else if(pos[i] * 2 > car[cnt].dis + car[cnt + 1].dis)
car[cnt + 1].num ++;
else car[cnt].num ++;
} for(int i = 1; i <= cnt1; i ++) {
cout << car[i].num;
printf("%s", i != cnt1 ? " " : "\n");
}
return 0;
}

  

Lyft Level 5 Challenge 2018-Final Round(Open Div.2) B. Taxi drivers and Lyft的更多相关文章

  1. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) (前三题题解)

    这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你 ...

  2. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) B 1075B (思维)

    B. Taxi drivers and Lyft time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2)

    A. The King's Race 签. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, ...

  4. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2)---ABC

    A---The King's Race http://codeforces.com/contest/1075/problem/A 题意: 一个人在\((1,1)\), 一个人在\((n,n)\), 现 ...

  5. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) C. The Tower is Going Home(思维+双指针)

    https://codeforces.com/contest/1075/problem/C 题意 一个宽为1e9*1e9的矩阵中的左下角,放置一个车(车可以移动到同一行或同一列),放置一些墙,竖的占据 ...

  6. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) A. The King's Race

    http://codeforces.com/contest/1075/problem/A On a chessboard with a width of nn and a height of nn, ...

  7. Lyft Level 5 Challenge 2018 - Final Round Div. 1没翻车记

    夜晚使人着迷.没有猝死非常感动. A:显然对于水平线段,只有横坐标的左端点为1的时候才可能对答案产生影响:对于竖直直线,如果要删一定是删去一段前缀.枚举竖直直线删到哪一条,记一下需要删几条水平线段就可 ...

  8. [Lyft Level 5 Challenge 2018 - Elimination Round][Codeforces 1033D. Divisors]

    题目链接:1033D - Divisors 题目大意:给定\(n\)个数\(a_i\),每个数的约数个数为3到5个,求\(\prod_{i=1}^{n}a_i\)的约数个数.其中\(1 \leq n ...

  9. Lyft Level 5 Challenge 2018 - Elimination Round

    A. King Escape 签. #include <bits/stdc++.h> using namespace std; ], y[]; int f1(int X, int Y) { ...

随机推荐

  1. 小记:vue 及 react 的工程项目入口小结及 webpack 配置多页面应用参考

    一.前言 闲暇时间,看了下前端的基础知识,有幸参与了公司公众号项目前面的一个阶段,学习到了一些前端框架的相关知识 小结了一下 自己练习通过新建一个个文件组织起项目的过程中的一些理解 二.项目入口 vu ...

  2. 使用bouncycastle进行DESede/DESeee/AES128/AES192/AES256的加解密

    前言 默认的jdk不支持DESeee的算法,本地化的JDK中配置有拦截规则,可以通过使用bouncycastle的jar包中的DESEngine类来进行DESeee算法的运算. DES的8字节加解密 ...

  3. IOS view拖拽(触摸事件)

    • iOS中的事件可以分为3大类型 触摸事件 加速计事件 远程控制事件 响应者对象 • 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并处理事 件.我们称之为“响应 ...

  4. Why malloc+memset is slower than calloc?

    https://stackoverflow.com/questions/2688466/why-mallocmemset-is-slower-than-calloc/ The short versio ...

  5. NOIP2018提高组Day2 解题报告

    前言 关于\(NOIP2018\),详见此博客:NOIP2018学军中学游记(11.09~11.11). \(Day2\)的题目和\(Day1\)比起来,真的是难了很多啊. \(T1\):旅行(点此看 ...

  6. 问题 F: 等比数列

    问题 F: 等比数列 时间限制: 1 Sec  内存限制: 64 MB提交: 2699  解决: 1214[提交][状态][讨论版][命题人:外部导入] 题目描述 已知q与n,求等比数列之和: 1+q ...

  7. MRCA|Wright–Fisher population genetic model|SNP rate

    (Panda has a high heterozygosity rate) 通过对mtDNA(为了预测SNP的密度)的分析,可知panda的多样性,当前全基因组数据才能完全建立模型. mitocho ...

  8. CVE-2018-4878

    0x00前言 该漏洞影响 Flash Player 版本28.0.0.137以及之前的所有版本 0x01 poc Poc 这里只列出关键代码 public function triggeruaf() ...

  9. SpringBoot学习记录(二)

    一. SpringBoot日志框架 SpringBoot:底层是Spring框架,Spring框架默认是用JCL(commons-logging): SpringBoot选用SLF4j和logback ...

  10. IDEA注释模板设置

    1. 文件注释 1.1 Java类文件注释 Setting -> Editor -> File and Code Templates -> Includes -> File H ...