#K8301. Visitor Points Calculation
Visitor Points Calculation
Visitor Points Calculation
You are given a list of visitors, where each visitor has a name
and a height
(in inches). You are to assign each visitor a certain number of points based on their height according to the following rules:
- If \(height < 50\), then points = 0.
- If \(50 \leq height \leq 60\), then points = 5.
- If \(61 \leq height \leq 70\), then points = 10.
- If \(height > 70\), then points = 15.
After assigning the points, sort the visitors by their points in descending order. In case of a tie in points, sort the visitors in alphabetical order by their names.
Your task is to read the input from stdin
and produce the sorted list where each line of output contains the visitor's name followed by their allocated points, separated by a space.
inputFormat
The first line of input contains an integer n
(\(0 \le n \le 10^5\)) representing the number of visitors. Each of the next n
lines contains a visitor's name
(a string without spaces) and height
(an integer), separated by space.
outputFormat
Output n
lines. Each line should contain the visitor's name and their calculated points, separated by a space, sorted by points in descending order, and if points are the same, sorted alphabetically by name.
4
Anna 62
Bella 55
Chris 72
Daniel 49
Chris 15
Anna 10
Bella 5
Daniel 0
</p>