Absolute Difference
You are given an array of non-negative integers [a1, a2, ..., an}].
In each step, you choose two elements x and y from the an array, remove them, and insert their mean value (x + y) / 2 back into the array.
This process continues until only two numbers, A and B, remain. Your goal is to determine the maximum possible absolute difference |A - B|.
Since the answer is not necessarily an integer, output the result modulo 10^9 + 7.
Example 1
Input:
[1, 2, 10, 11]
Output:
9
Example 2
Input:
[1, 2, 3]
Output:
500000005
main.cpp
C++
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat