Олимпиадный тренинг

Задача 39015. Garland brightness. Training task - 2


Ded Moroz's factory produces light bulbs of various weights and brightness. The weight of the bulb does not exceed 100 grams, the brightness of the bulb does not exceed 10,000 lumens. 
K of the brightest light bulbs are selected to make a New Year's garland. If the brightness of two bulbs is the same and they all do not fit in a garland, then place a bulb with a smaller weight.
Information is known about the weight and brightness of each light bulb brought to the workshop to form a New Year's garland.
Determine the total weight of the bulbs in the garland and the average brightness of the entire garland.

Input and output data
In file in the first line space-separated numbers N are written - the number of light bulbs brought to the workshop (natural number, not exceeding 1000) and K –  the number of light bulbs in the garland (a natural number not exceeding 100). Each of the following N lines contains two numbers – the weight and brightness of each bulb.
Write in the answer two numbers – first, the total weight of the bulbs in the garland, then the average brightness of the entire garland (only the whole part).

An example of the organization of source data in the input file:

9 4
50 600
60 480
45 540
30 300
15 180
70 560
30 360
91 910
40 320


Response: 256 652