eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Joint Venture

Joint Venture

\includegraphics{https://static.e-olymp.com/content/86/86de37bc878f19d27c73279777a794e51b0fffb0.jpg} Liesbeth and Jan are building a robot for a course project and have discovered that they need to fit two pieces of Lego into an opening. The opening is x centimetres wide and the sum of the lengths of the two pieces has to be precisely equal to the width of the opening, or else the robot will break during the project demonstration, with catastrophic consequences for the grades of the two students. Luckily, Liesbeth and Jan were able to sneak into the physics laboratory late one night to measure the lengths of their remaining Lego pieces very accurately. Now they just need to select two pieces that will fit the opening perfectly. \InputFile For each test case, you get: \begin{itemize} \item a line containing one positive integer: \textbf{x}, denoting the width of the opening in centimetres, with \textbf{1} ≤ \textbf{x} ≤ \textbf{20}. \item a line containing one non-negative integer: \textbf{n}, denoting the remaining number of Lego pieces Liesbeth and Jan have access to, with \textbf{0} ≤ \textbf{n} ≤ \textbf{1000000}. \item \textbf{n} lines containing positive integers \textbf{l}, denoting lengths of Lego pieces in nanometres. Liesbeth and Jan have told you that no piece of Lego is longer than \textbf{10} centimetres, or \textbf{100000000} nanometres. \end{itemize} \OutputFile For each test case, a row containing the word '\textbf{danger}' if no two pieces of Lego exist that precisely fit into the opening, or '\textbf{yes l_1 l_2}', with \textbf{l_1} ≤ \textbf{l_2}, should two such pieces of lengths \textbf{l_1} and \textbf{l_2} exist. In case multiple solutions exist, a solution maximising the size difference \textbf{|l_1-l_2|} must be printed.
Ліміт часу 10 секунд
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1
4
9999998
1
2
9999999
Вихідні дані #1
yes 1 9999999
Джерело NWERC 2012 - NorthWestern European Regional Championship 2012