Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C PROGRAMMING LANGUAGE JUST USE LIBRARY STDIO.H AND STRING.H ONLY AND USE MERGE SORT ONLY BMI Sorting Machine[EN] You are given data where each

USE C PROGRAMMING LANGUAGE JUST USE LIBRARY STDIO.H AND STRING.H ONLY AND USE MERGE SORT ONLY

BMI Sorting Machine[EN]

You are given data where each data consists of ID, name, and heigh in foot and inch. Then, there are queries. For each query, given a variable which represents a height in cm. You are asked for help to display all data whose height is less than or equal to , ordered descending by the height. If there are 2 data which has the same height, sort ascending by the ID. If no data satisfies the query, output -1.

Note that 1 foot = 12 inch, and 1 inch = 2,54 cm.

Input Format

The first line consists of an integer . The next lines consists of the given data in the format A,B,C D where A, B, C, and D represent ID, name, height in feet, and height in inch, respectively. The next line consists of an integer . The next lines consist of an integer which represents the query.

Output Format

Each query is started by Q, followed by the query number started from 1, followed by :. For each query, if there is data to display, then output the data sorted descending based on the height with the following format: . If there is no data to display, output -1.

Constraints

1 5 10^4

ID is an integer between 1 and . It is guaranteed that 2 data will not have the same ID.

Length of each name is between 1 and 20 (inclusive). Names consist of Latin alphabet or whitespace. It is guaranteed that the first and last character are not whitespaces.

Height in foot is between 0and 7 (inclusive). Height in inch is between 0 and 11 (inclusive).

1 200

Subtask 1 (80 point): 1 102

Subtask 2 (20 point): No additional constraint

Sample Input

Sample Output

5

1,John Doe,4 6

2,Anonymous,5 4

3,Vohu Manah,6 1

4,Dora Hariwini,5 4

5,Kyo,6 7

3

165

130

200

Q1:

2 Anonymous 162.56

4 Dora Hariwini 162.56

1 John Doe 137.16

Q2:

-1

Q3:

3 Vohu Manah 185.42

2 Anonymous 162.56

4 Dora Hariwini 162.56

1 John Doe 137.16

Notes

In this problem, there are subtasks. If your solution can only solve subtask 1, then you will get 80 points. For example, your program is not efficient enough such that it can solve the problem with the constraint program 1 102 under the 1 second time limit, but unable to solve larger value of , such as = 5 104 .

Note that for this problem, if your program can solve subtask 2, then the program can solve subtask 1 as well. Therefore, if your program can solve this problem within all of the constraints, then your solution is considered correct and you will get 100 points.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

Students also viewed these Databases questions

Question

3. Uncover needs:

Answered: 1 week ago