Click here to Skip to main content
15,357,967 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
A. 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: "<ID> <Name> <Height in cm>".
If there is no data to display, output "-1".
• 1 ≤ 𝑁 × 𝑀 ≤ 5 × 104
• 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 0 and 7 (inclusive). Height in inch is between 0 and 11 (inclusive).
• 1 ≤ 𝑥 ≤ 200
Subtask 1 (80 points):
• 1 ≤ 𝑁 ≤ 102
Subtask 2 (20 points):
• No additional constraint
Sample Input Sample Output
1,John Doe,4 6
2,Anonymous,5 4
3,Vohu Manah,6 1
4,Dora Hariwini,5 4
5,Kyo,6 7
2 Anonymous 162.56
4 Dora Hariwini 162.56
1 John Doe 137.16
3 Vohu Manah 185.42
2 Anonymous 162.56
4 Dora Hariwini 162.56
1 John Doe 137.16
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

What I have tried:

im too stupid and i didnt try anything can anyone help me to solve this quetion
Updated 14-Feb-21 23:38pm
Rick York 15-Feb-21 3:44am
I would start by reading the file and parsing the data. The functions fopen and fgets are useful.

im too stupid and i didnt try anything can anyone help me to solve this quetion

No, because you don't want help, you want us to do the job and give you a working solution so you can claim it is yours. It is rude of you.
For this kind of service, you should think about hiring a professional.
Advice: if you are so stupid that you can't even start thinking about the problem, turn away from computer programming.

You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
Your arent too stupid, because you have aknowledged one part of your problem: your missing knowledge. Read my article How to start ... with some tips and links to start your solution.

tip: take care of some design, like classes and functions. And seperate each task in a function or class.
im too stupid and i didnt try anything

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900