wip
Time Limit: 1 seconds
Memory Limit: 1024 MB
Rating: 1000
Problem StatementEarth is your reference point. You will be given a list of numbers, representing the planets' distances from Earth. Sort the distances in an ascending order. Return the NAMES of the planets in ascending order of distance. HINT: Be mindful of distances in the negative direction.
Input1st input: a string of REAL numbers representing distances, separated by a space. 2nd input: a string of names of the planets, separated by a space. First input $m$: $1 ≤ |m| ≤ 10^3$ Real number $x$ in input $m$: $-10^3 ≤ x ≤ 10^3$ Second input $n$: $1 ≤ |n| ≤ 10^3$
OutputA single string, with the names of each planet in ascending order of distance, separated by a space. Your string must not start with a space. there should be a single space at the end of your string. If two planets are the same distance away, the planet that appears first in the original input should be first in the output.
Sample CasesSample Input 0: 7.0 2.3 Jupiter Mars Sample Output 0: Mars JupiterExplanation
The first input are the distances, the second the name of the planets. The first distance corresponds with the first name, therefore Jupiter has a distance of 7.0 units from Earth, and Mars has a distance of 2.3 units. As Mars is closer to Earth than Jupiter, the final output should be "Mars Jupiter" with a single space at the end of the string.
SourcesKL Coding Cup October 2024 > Problem 11
Submit | Back