SOLENN AND HER SUITORS
Solenn has many suitors. To pick a partner, she has the following criteria: her partner's height and weight must be close to hers. Her suitors also want to know how many suitors ranked ahead of them (maybe they want to "get rid" of the other suitors?). Your task is to help Solenn rank her suitors based on her criteria. The suitors with small height differences with her must be at the top, and the suitors with big height differences must be at the bottom. If there are ties, break the tie according to their weight differences. If there are still ties, rank them alphabetically (yes, she is that superficial, unfortunately). Input: First line contains the number of problems to be solved, say X. This is followed by X number of chunks of data in this format: First line of the chunk contains two numbers, which is Solenn's height(in centimeters) and weight(in kg) separated by space. This is followed by a number, say s, which is the number of suitors Solenn has. This is then followed by s lines of data for each suitor which is formatted this way: "<name> <height in centimeters> <weight in kg>" Output: For each problem, print the ordering of Solenn's suitors (names only) based on her criteria, where the first one has the best score, separated by space. ** Example Input:** 1 170 60 8 Allen 168 58 Wendell 166 60 Marlon 165 60 Brian 165 60 Christopher 172 57 Rene 175 65 Mark 169 75 Kelvin 170 58 **Expected Output:** Kelvin Mark Allen Christopher Wendell Brian Marlon Rene`
must be implemented/code using C. I badly need an answer asap.
Edited 4 Years Ago by binaryjc