A kiln has n temperature sensors (n is even), each reporting an integer reading. A technician performs n/2 calibration rounds. In each round, among the sensors not yet retired, she finds the current coldest reading and the current hottest reading, retires both, and logs their average. After all rounds are complete, report the smallest logged average across all n/2 rounds -- this identifies the weakest-calibrated pair. Because a retired pair's two readings always sum to an integer, each logged average is either a whole number or ends in exactly .5; print it with exactly one digit after the decimal point.
Line 1: integer n (even).
Line 2: n space-separated integers, the sensor readings.
A single number: the minimum logged pair average, printed with exactly one decimal digit (e.g. 4.0 or 3.5).
2 <= n <= 50
n is even
0 <= reading[i] <= 100
Example 1
Input
4 7 9 8 2
Expected
5.5
Explanation
Round 1 retires the coldest (2) and hottest (9) remaining readings, logging average (2+9)/2=5.5. Round 2 retires the remaining 7 and 8, logging (7+8)/2=7.5. The minimum of the logged averages is 5.5.
Example 2
Input
4 4 4 4 4
Expected
4.0
Explanation
Every reading is 4, so both rounds retire a (4,4) pair and log average 4.0. The minimum logged average is 4.0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →