vile
A number of n beautiful houses have been built alongside the Sun Freeway, numbered in order, from 1 to n. Each house is inhabited by a Solarian. The administration has concluded that Solarians get along the better the smaller the age difference between them is, and for this reason it is interested in finding out the maximum age difference between any two neighbors.
Task
Knowing the age of every Solarian, find out the maximum age difference between two neighbors. By Solarian neighbors we understand two inhabitants for whom the module of their houses' numbers doesn't exceed k.
Input Data
Line one of input file vile.in contains numbers n and k, separated by a space. The following n lines contain n positive integers, representing, in order, the Solarians' ages.
Output Data
The first line of file vile.out will contain the maximum difference found.
Restrictions
Example
vile.in |
vile.out |
6 2 |
6 |
Time limit: 0.1 seconds/test
Memory limits: data segment: 2 Mb; stack segment: 1 Mb.
prof. Nistor Mot
Brăila "N.Balcescu" National High School
Contact:emotz_ro@yahoo.co.uk