CF1662L.Il Derby della Madonnina
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely the side of the field, always looking very carefully at the match to check for offside positions and other offences.
Football is an extremely serious matter in Italy, and thus it is fundamental that you keep very close track of the ball for as much time as possible. This means that you want to maximise the number of kicks which you monitor closely. You are able to monitor closely a kick if, when it happens, you are in the position along the touch-line with minimum distance from the place where the kick happens.
Fortunately, expert analysts have been able to accurately predict all the kicks which will occur during the game. That is, you have been given two lists of integers, t1,…,tn and a1,…,an, indicating that ti seconds after the beginning of the match the ball will be kicked and you can monitor closely such kick if you are at the position ai along the touch-line.
At the beginning of the game you start at position 0 and the maximum speed at which you can walk along the touch-line is v units per second (i.e., you can change your position by at most v each second). What is the maximum number of kicks that you can monitor closely?
米兰与国际米兰之间的德比大战即将打响,你被选为本场比赛的助理裁判(即边裁)。你的任务是沿着边线(球场侧面)移动,同时始终密切观察比赛,以判断越位位置及其他犯规行为。
足球在意大利是一项极其严肃的运动,因此尽可能长时间地紧盯着足球至关重要。这意味着你需要最大化自己能够密切监控的踢球次数。当一次踢球发生时,若你当时所处的边线位置与该次踢球发生的位置之间的距离最小,则你便能对该次踢球进行密切监控。
幸运的是,专业分析师已能精确预测比赛中所有将要发生的踢球事件。具体而言,你获得了两个整数列表:t1,…,tn 和 a1,…,an,其中表示比赛开始后 ti 秒将发生一次踢球,且若你在边线上处于位置 ai,则可对该次踢球进行密切监控。
比赛开始时,你位于位置 0,而你沿边线行走的最大速度为 v 单位/秒(即每秒最多移动 v 单位距离)。你最多能密切监控多少次踢球?
输入格式
The first line contains two integers n and v (1≤n≤2⋅105, 1≤v≤106) — the number of kicks that will take place and your maximum speed.
The second line contains n integers t1,…,tn (1≤ti≤109) — the times of the kicks in the match. The sequence of times is guaranteed to be strictly increasing, i.e., t1<t2<⋯<tn.
The third line contains n integers a1,…,an (−109≤ai≤109) — the positions along the touch-line where you have to be to monitor closely each kick.
第一行包含两个整数 n 和 v(1≤n≤2⋅105,1≤v≤106)—— 分别表示将要发生的踢球次数以及你的最大速度。
第二行包含 n 个整数 t1,…,tn(1≤ti≤109)—— 表示比赛中各次踢球发生的时间。时间序列保证严格递增,即 t1<t2<⋯<tn。
第三行包含 n 个整数 a1,…,an(−109≤ai≤109)—— 表示为密切监视每次踢球,你必须在边线上的对应位置。
输出格式
Print the maximum number of kicks that you can monitor closely.
输出你可以密切监控的最大踢球次数。
输入输出样例
输入#1
3 2 5 10 15 7 17 29
输出#1
2
输入#2
5 1 5 7 8 11 13 3 3 -2 -2 4
输出#2
3
输入#3
1 2 3 7
输出#3
0
说明/提示
In the first sample, it is possible to move to the right at maximum speed for the first 3.5 seconds and stay at position 7 until the first kick happens, and then immediately move right also at maximum speed to watch the second kick at position 17. There is no way to monitor closely the third kick after the second kick, so at most 2 kicks can be seen.
在第一个样例中,可以以最大速度向右移动最多 3.5 秒,并在位置 7 处停留直至第一次踢球发生,然后立即以最大速度向右移动,以便在位置 17 处观看第二次踢球。在第二次踢球之后,无法再紧密监控第三次踢球,因此最多只能看到 2 次踢球。
输入解题思路,AI测评打分。不知道怎么写?