After buying a new wand, Megumin wants to test it out on some bombs. She finds bombs lined up in a row. The bomb is on a tower meters high. A bomb explodes when Megumin manually detonates it or when an adjacent bomb with a height difference of less than or equal to explodes. How many bombs does Megumin need to manually detonate for all bombs to explode? Additionally, among all shortest ways to detonate all bombs, what is the largest single chain reaction that can be created?
Constraints
Subtask 1 [5/15]
Subtask 2 [10/15]
No additional constraints.
Input Specification
The first line of input contains integers, , the number of bombs, and , the maximum difference in height allowed for a bomb to set off an adjacent bomb.
The second line of input contains space separated integers, , the height of each bomb.
Output Specification
On the first line, output a single integer, the number of bombs Megumin needs to manually detonate for all bombs to explode.
On the second line, output a single integer, the largest explosion (in terms of count) that can be created from manually detonating a single bomb.
Sample Input
8 3
10 7 5 9 1 1 7 10
Sample Output
4
3
Explanation for Sample Output 1
In total, Megumin needs to set off bombs for everything to explode. One way to do this is setting off bombs , , , and .
The largest explosion can be created by setting off bomb , this will set off bomb since , which sets off bomb since . In total, bombs exploded from setting off a single bomb.
Comments