HALLOWEEN EVE - APOC2_02 - EDITORIAL
Vector,Sorting,Arrays and Subsets
In some other world, today is Halloween Eve.There are N trees planted in Mr. Smithís garden. The height of the i-th tree (1=i=N) is h i meters.
He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the
decorated trees should be as close to each other as possible.More specifically, let the height of the tallest decorated tree be hmax meters,
and the height of the shortest decorated tree be hmin meters.The smaller the value hmax-hmin is, the better. What is the minimum possible value
h i is an integer.
Input is given from Standard Input in the following format: N K
Print the minimum possible value of hmax-hmin.
Get the input in the given format. Find the difference between minimum and maximum of all possible K-subsets.Store the minimum of the difference
in a variable.Output the minimum stored in the variable.
Example Test Case:
In the above example,
Find the difference of maximum and minimum in a subset of 3.
Hence the minimum difference is 2.
using namespace std;