问题4074--Joint Venture

4074: Joint Venture

[命题人 : ]
时间限制 : 10.000 sec  内存限制 : 128 MB

题目描述

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.

输入

For each test case, you get:
 a line containing one positive integer: x, denoting the width of the opening in centime- tres, 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 l, 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.

输出

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.

样例输入 Copy

1
4
9999998
1
2
9999999

样例输出 Copy

yes 1 9999999

来源/分类

NWERC 2012