Joint Venture
Time Limit: 10 Seconds Memory Limit: 131072 KB
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.
Input
For each test case, you get:
• a line containing one positive integer: x, denoting the width of the opening in centimetres, with 1 ≤ x ≤ 20.
• a line containing one non-negative integer: n, denoting the remaining number of Lego pieces Liesbeth and Jan have access to, with 0 ≤ n ≤ 1000000.
• n lines containing positive integers , denoting lengths of Lego pieces in nanometres. Liesbeth and Jan have told you that no piece of Lego is longer than 10 centimetres, or 100000000 nanometres.
Output
For each test case, a row containing the word ‘danger’ if no two pieces of Lego exist that precisely fit into the opening, or ‘yes l1 l2 ’, with l1 ≤ l2 , should two such pieces of lengths l1 and l2 exist.
In case multiple solutions exist, a solution maximising the size difference |l1-l2| must be printed.
Sample Input
1 4 9999998 1 2 9999999
Sample Output
yes 1 9999999Submit
Source: NWERC 2012