Elemental Monuments
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

There are many ancient elemental monuments left on the continent of Teyvat. An elemental monument is a magical ancient mechanism, deeply rooted in the ground and unable to move.

Paimon is now solving a puzzle at some location. Here, there are n elemental monuments arranged in a line. From left to right, the coordinate of the i-th monument is x_i, and each monument has one of two attributes: ice or fire.

If two monuments have different attributes, and the distance between them is strictly less than 2S, then one piece of elemental particle will appear at their midpoint. A position may produce multiple pieces of elemental particles.

The puzzle requires collecting only the elemental particles that appear at integer coordinates, and the number of collected particles is the password to open the chest. Paimon asks you, the Traveler, for help. How many elemental particles will be collected in the end?

输入描述:

The first line contains two positive integers n, S (1 \le n \le 2 \times 10^5, 1 \le S \le 10^9), representing the number of elemental monuments and the distance parameter (as described in the statement).

The second line contains n positive integers x_1, x_2, \ldots, x_n (-10^9 \le x_1 < x_2 < \ldots < x_n \le 10^9), representing the coordinates of the monuments.

The third line contains n integers t_1, t_2, \ldots, t_n (t_i \in \{0, 1\}), representing the attribute of each monument. t_i = 0 means fire, and t_i = 1 means ice.

输出描述:

Output one line containing an integer, representing the final number of elemental particles collected.
示例1

输入

复制
7 4
1 2 3 4 5 6 7
0 0 1 1 0 0 1

输出

复制
6