Codey and Jutsu
https://www.hackerrank.com/contests/codenection-2024-final-round-closed-category/challenges/cn24-13
Question
Codey has mastered the clone jutsu recently, and it's now on a mission with its weapon to fire n aliens.
Codey creates n copies of itselves, each positioned on the y-axis of a 2D plane, while the aliens are positioned on the x-axis. No one will be at the origin, and they can't move around. Every "Codey" should fire exactly one alien. If Codey at point uses his weapon to fire an alien at point , the fire distance will be (the distance between the points).
Input Format
The first line contains an integer n, where n represents the number of Codey copies and aliens.
The following lines contain two space-separated integers x and y, which represent a clone or alien's position.
Constraints
It is guaranteed that no point is at the origin.
It is guaranteed that the number of points on the x-axis is equal to n and the number of points on the y-axis is equal to n.
Output Format
Output the minimal sum of all fire distances. Your answer is considered correct if its absolute or relative error does not exceed .
Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if .
To set precision when printing values you can use:
print(f"{distance:.9f}")
in Python;std::cout << fixed << std::setprecision(9) << distance << std::endl;
in C++;System.out.printf("%.9f\n", distance);
in Java;console.log(distance.toFixed(9));
in JavaScript;printf("%.9f\n", distance);
in C.
Sample Inputs:
Last updated