CF474E.Pillars

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Marmot found a row with nn pillars. The ii -th pillar has the height of hih_{i} meters. Starting from one pillar i1i_{1} , Marmot wants to jump on the pillars i2i_{2} , ..., iki_{k} . ( 1<=i1<i2<...<ik<=n1<=i_{1}<i_{2}<...<i_{k}<=n ). From a pillar ii Marmot can jump on a pillar jj only if i<ji<j and hihj>=d|h_{i}-h_{j}|>=d , where x|x| is the absolute value of the number xx .

Now Marmot is asking you find out a jump sequence with maximal length and print it.

输入格式

The first line contains two integers n and d (1 ≤ n ≤ 10^5, 0 ≤ d ≤ 10^9).

The second line contains n numbers h1, h2, ..., hn (1 ≤ hi ≤ 10^15).

输出格式

The first line should contain one integer k, the maximal length of a jump sequence.

The second line should contain k integers i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n), representing the pillars' indices from the maximal length jump sequence.

If there is more than one maximal length jump sequence, print any.

输入输出样例

  • 输入#1

    5 2
    1 3 6 7 4
    

    输出#1

    4
    1 2 3 5 
    
  • 输入#2

    10 3
    2 1 3 6 9 11 7 3 20 18
    

    输出#2

    6
    1 4 6 7 8 9 
    

说明/提示

In the first example Marmot chooses the pillars 11 , 22 , 33 , 55 with the heights 11 , 33 , 66 , 44 . Another jump sequence of length 44 is 11 , 22 , 44 , 55 .

首页