P24980 [AtCoder] [ARC043A] Score Conversion
普及
题目描述

Problem Description

$ N $ people took a test. The score of the $ i $th person is $ S_i $.

Due to the uneven distribution of scores, we want to convert the scores so that the average is $ A $ and the difference between the maximum and minimum values is $ B $.

The conversion is done by choosing appropriate real numbers $ P $ and $ Q $. The converted score for the $ i $th person is $P \times S_i + Q$.

Determine if there are appropriate $ P $ and $ Q $, and if so, output them.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A $ $ B $ $ S_1 $ $ S_2 $ : $ S_N $

  • The first line contains the number of people who took the test, an integer $N\ (2 \leq N \leq 10^5)$, the desired average after conversion, an integer $A\ (1 \leq A \leq 10^9)$, and the desired difference between the maximum and minimum values after conversion, an integer $B\ (1 \leq B \leq 10^9)$, all separated by spaces.
  • The next $ N $ lines contain the score of the $ i $th person, an integer $S_i\ (0 \leq S_i \leq 10^9)$.

Output Format

If no appropriate conversion exists, output $ -1 $ on a single line.

If an appropriate conversion exists, output $ P $ and $ Q $ separated by spaces on a single line. The output is accepted if the absolute or relative error is at most $ 10^{-6} $.

End the output with a newline.

Sample Input and Output

Sample Input #1

5 2 4
2
4
6
8
10

Sample Output #1

0.5 -1

Sample Input #2

13 29 31
3
1
4
1
5
9
2
6
5
3
5
8
9

Sample Output #2

3.875 10.8173076

Sample Input #3

5 1 2
34
34
34
34
34

Sample Output #3

-1

Notes/Hints

Sample Explanation 1

With $ P = 0.5 $ and $ Q = -1 $, the scores become $ 0, 1, 2, 3, 4 $ in order, resulting in an average of $ 2 $ and a difference between the maximum and minimum values of $ 4 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 2 4 2 4 6 8 10
样例输出
0.5 -1