eolymp
bolt
Try our new interface for solving problems
Məsələlər

Joint Venture

Joint Venture

Zaman məhdudiyyəti 10 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

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.

Giriş verilənləri

For each test case, you get:

  • a line containing one positive integer: x, denoting the width of the opening in centimetres, with 1x20.

  • a line containing one non-negative integer: n, denoting the remaining number of Lego pieces Liesbeth and Jan have access to, with 0n1000000.

  • 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.

Çıxış verilənləri

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 l_1 l_2', with l_1l_2, should two such pieces of lengths l_1 and l_2 exist. In case multiple solutions exist, a solution maximising the size difference |l_1-l_2| must be printed.

Nümunə

Giriş verilənləri #1
1
4
9999998
1
2
9999999
Çıxış verilənləri #1
yes 1 9999999
Mənbə NWERC 2012 - NorthWestern European Regional Championship 2012