Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Top K Obese Classes
Question:
School doctor wants to start a campaign against
obesity. She wants to work on top k fat classes.
And, she has announced that she is going to
calculate class Body Mass Indexes (BMI) and
the most fit class will be awarded where
BMI = weightInKilograms / (heightInMeters * heightInMeters)
Write a program that is going to read student weight
and height information from n classes and the program will
define the top k classes (whose BMI is the biggest).
Input specification:
First, you will be given two integers: the number of
classes (n) and the number of top (k) classes to list.
The following n lines will start with an integer (m) and
will be followed by m pairs of numbers: an integer
(weightInKilograms) and a floating point number
(heightInMeters). Each pair will be followed by a semicolon
where 1 ≤ n ≤ 1,000 and 1 ≤ m ≤ 60.
Output specification:
Show k integers (orders of top k classes).
If there are two classes with the same BMI
average (if the BMI difference between two
classes is smaller than 0.0001), first
show the one with the smaller
class ID (order of class).
Sample Input
6 3
3 54 1.74; 45 1.46; 36 1.33;
4 35 1.86; 51 1.65; 65 1.74; 57 1.99;
3 67 1.79; 44 1.32; 47 1.40;
3 58 1.33; 54 1.40; 42 1.49;
4 70 1.34; 56 1.30; 49 1.33; 48 1.32;
2 65 1.35; 38 1.88;
|
Sample Output
5 4 3
|
Explanation:
There are 6 classes given, and the top 3 classes will be listed.
BMI of the 3 people in the first class are: 17.84, 21.11, and 20.35.
And thus the class BMI average is 19.766. The table below, lists the
class BMI averages:
Class ID |
Class BMI |
1 |
19.766 |
2 |
16.178 |
3 |
23.381 |
4 |
26.419 |
5 |
31.842 |
6 |
23.208 |
Для отправки решений необходимо выполнить вход.
|