Let's say the HR team of a company has goodies set of size N each with a different price tag for each goodie. Now the HR team has to distribute the goodies among the M employees in the company such that one employee receives one goodie. Find out the goodies the HR team can distribute so that the difference between the low price goodie and the high price goodie selected is minimum.Input:Goodies and Prices:Fitbit Plus: 7980IPods: 22349MI Band: 999Cult Pass: 2799Macbook Pro: 229900Digital Camera: 11101Alexa: 9999Sandwich Toaster: 2195Microwave Oven: 9800Scale: 4999Example OutputNumber of the employees: 4Here the goodies that are selected for distribution are:Fitbit Plus: 7980Microwave Oven: 9800Alexa: 9999Digital Camera: 11101And the difference between the chosen goodie with highest price and the lowest price is 3121Number of employees: 6Here the goodies that are selected for distribution are:Sandwich Toaster: 2195Cult Pass: 2799Scale: 4999Fitbit Plus: 7980Microwave Oven: 9800Alexa: 9999And the difference between the chosen goodie with highest price and the lowest price is 7804Number of employees: 2Here the goodies that are selected for distribution are:Microwave Oven: 9800Alexa: 9999And the difference between the chosen goodie with highest price and the lowest price is 199The input has to be read from a file. The input file contains the all the goodies and their prices as shown in the example input file sample_input.txt in the current folder . The output has to be written to a file as shown in the example output file sample_output.txt in the current folder.Usage of any libraries provided by the language or the framework used is restricted, except for the Mathematics and the I/O libraries.
Let's say the HR team of a company has goodies set of size N each with a different price tag for each goodie. Now the HR team has to distribute the goodies among the M employees in the company such that one employee receives one goodie. Find out the goodies the HR team can distribute so that the difference between the low price goodie and the high price goodie selected is minimum.
Input:
Goodies and Prices:
Fitbit Plus: 7980
IPods: 22349
MI Band: 999
Cult Pass: 2799
Macbook Pro: 229900
Digital Camera: 11101
Alexa: 9999
Sandwich Toaster: 2195
Microwave Oven: 9800
Scale: 4999
Example Output
Number of the employees: 4
Here the goodies that are selected for distribution are:
Fitbit Plus: 7980
Microwave Oven: 9800
Alexa: 9999
Digital Camera: 11101
And the difference between the chosen goodie with highest price and the lowest price is 3121
Number of employees: 6
Here the goodies that are selected for distribution are:
Sandwich Toaster: 2195
Cult Pass: 2799
Scale: 4999
Fitbit Plus: 7980
Microwave Oven: 9800
Alexa: 9999
And the difference between the chosen goodie with highest price and the lowest price is 7804
Number of employees: 2
Here the goodies that are selected for distribution are:
Microwave Oven: 9800
Alexa: 9999
And the difference between the chosen goodie with highest price and the lowest price is 199
The input has to be read from a file. The input file contains the all the goodies and their prices as shown in the example input file sample_input.txt in the current folder .
The output has to be written to a file as shown in the example output file sample_output.txt in the current folder.
Usage of any libraries provided by the language or the framework used is restricted, except for the Mathematics and the I/O libraries.
Comments
Post a Comment