eolymp
bolt
Try our new interface for solving problems
Problems

Fair Game

Fair Game

In an elementary school, children enjoy playing a game. The game is played by two persons. First, a parameter \textbf{x} and \textbf{N} items are given. The \textbf{i}^th item has a value \textbf{c_i}. Two players take an item in turn. If a player takes the \textbf{i}^th item in the \textbf{t}^th turn, he earns score of \textbf{sin(x+t+c_i)} points, where \textbf{x}, \textbf{t} and \textbf{c_i} are interpreted in radian. \textbf{t} is \textbf{1} for the first player’s first turn, for the second player’s first turn \textbf{t} is \textbf{2}, and so on. Each player’s objective is to maximize his total score minus the opponent’s total score. Although the children have been enjoying the game, one day, some of the parents have claimed that the game is unfair because either player may definitely lose no matter how he plays wisely. The parents, as fierce as monsters, requested to make the game fair, i.e. two players get same amount of score when both play optimally. To satisfy the request, teachers of the elementary school decided to introduce a handicap. Let’s consider another parameter \textbf{w}. For the parameters \textbf{x} and \textbf{w}, the following value is added to the first player’s score: \includegraphics{https://static.e-olymp.com/content/06/06623aaf984da01e54af947172b877ae149fe5c7.jpg} Now, for given \textbf{w} and items, is there any \textbf{x} which makes the game fair? Write a program to find \textbf{x}. \InputFile The first line of input contains two integers \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{14}) and \textbf{w} (\textbf{1} ≤ \textbf{w} ≤ \textbf{100000}). \textbf{N} denotes the number of items, and \textbf{w} is a parameter which is described above. Following \textbf{N} lines describe values for each item. The \textbf{i}^th line stands for integers \textbf{c_i} (\textbf{1} ≤ \textbf{c_i} ≤ \textbf{100000}). \OutputFile Output \textbf{x} which makes the game fair. If there is no such \textbf{x}, output "\textbf{impossible}" (without quotes) instead. When there exists such \textbf{x}, your output will be accepted if the absolute value of the difference of two players’ scores is no greater than \textbf{10^\{-3\}} when they play optimally. If there are multiple answers, any of them will be accepted.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2 4
1
2
Output example #1
7.004114228712096
Source The 2011 35th Annual ACM Programming Contest Winter Camp