DMPG '18 B6 - House of Cards

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Mimi is building a house of cards! However, being the strange person that she is, she has premade layers of cards, with width .

Mimi proceeds to build a house of cards by stacking the layers of cards, one on top of another. However, she realizes that people will become suspicious if the layers are too similar in width, or if the stack grows wider as it gets taller. Thus if layer is stack on top of layer , the width of layer must be at least less than .

Given these constraints, what is the tallest house of cards Mimi can make?

Input Specification

The first line will have two space separated integers, and .
The next line will have space separated integers, , the widths of the card layers.

Output Specification

A single integer, the number of layers in the tallest house of cards Mimi can make.

Sample Input

5 4
7 2 20 9 12

Sample Output

4