Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
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

main.cpp

C++

AIに質問する

expand

AIに質問する

ChatGPT

䜕でも質問するか、提案された質問の1぀を詊しおチャットを始めおください

some-alt