Under construction

Still being built. Things may change

Skokovi

Interview

Time limit5sMemory limit1024 MB

Summary
Given flower heights and a limit K, mark which flowers a grasshopper can reach from the first one by jumping only rightward to flowers whose height differs by at most K.
Level

Medium5 of 10

Topics
Dynamic programming, Segment tree
Solved
No attempts yet

Problem

In a land who knows where, in a world who knows when, lives a bee named Maya. Her adventure-filled life is an endless source of ideas for tasks, so we chose one of them. Maya's friend, a grasshopper named Filip, is preparing for the Olympics in flower jumping. The meadow has NN flowers in a row, and flower ii has height aia_i, a positive integer. Filip always jumps from left to right. From flower ii, he can jump to flower jj if and only if i<ji < j and ∣ai−aj∣≤K|a_i - a_j| \le K, where KK is a given positive integer. Starting from the leftmost flower, determine which flowers Filip can reach.

Input

The first line contains positive integers NN (1≤N≤2⋅1051 \le N \le 2 \cdot 10^5) and KK (1≤K≤1091 \le K \le 10^9). The second line contains NN positive integers a1,…,aNa_1, \dots, a_N (1≤ai≤1091 \le a_i \le 10^9), the heights of the flowers.

Output

Print NN numbers, each either 00 or 11, on a single line. The ii-th number is 11 if flower ii is reachable and 00 otherwise. The first flower is always reachable, since Filip starts there.

Examples2

  1. Example 1

    Input
    5 2
    5 4 8 7 2
    
    Expected output
    1 1 0 1 1
    
  2. Example 2

    Input
    5 3
    10 15 14 8 9
    
    Expected output
    1 0 0 1 1