-->
当前位置:首页 > 题库

PROGRAMMING:Graduation photo

Luz5年前 (2021-05-10)题库453
According to the graduation photo must line up, or someone will be blocked, causing lifelong regret. Suppose there are n graduates who are going to line K. The photographer who takes the graduation photos sets the following rules:
1. The number of people in each row must be n / K. if there are many students, they all stand in the last row;
2. The students in the back row must not be shorter than any of the students in the front row;
3. In any row, in the middle of the tallest station, the second tallest station is on his right, the third tallest station is on his left, and the fourth tallest station is on his right, so they rotate in turn. For example, if there are five students whose heights are 190 cm, 188 cm, 186 cm, 175 cm and 170 cm, they should be ranked 175188, 190186170. Here we assume that the photographer stands facing the students, so the left hand of the photographer is the right hand of the students.
4. If they are of the same height, they should be arranged in ascending order according to the alphabetic order of the names. We assume that there are no duplicate names.
###Input format:
Each input includes a test case. The first line has two positive integers n and K, where n is the total number of graduates and K is the number of rows. N < = 10000, K < = 10, followed by N lines, the names with no more than 8 characters and their height are given respectively, and the names do not contain spaces.
###Output format:
For each group of input, the position of graduates when taking photos will be displayed. It is required to print the names of students in line K. The names should be separated by a space, and there should be no extra space at the end of the line. Because you are for graduates, the students in the last row should be displayed in the first row, and the students in the first row should be displayed in the last row.
###Input example:
Here is a set of inputs. For example:
```in
10 3
Tom 188
Mike 170
Eva 168
Tim 160
Joe 190
Ann 168
Bob 175
Nick 186
Amy 160
John 159
```
###Output example:
The corresponding output is given here. For example:
```out
Bob Tom Joe Nick
Ann Mike Eva
Tim Amy John
```







answer:If there is no answer, please comment