HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50340 - Game 19

Guest
• Discussion of problem (1)

Volume problems

• 50708 - Binary Strings
• 50694 - The Cheapest Flight
• 50996 - Checkers - the shortest path
• 50770 - Average Depth
• 50291 - Postfix Arithmetic Expressions
• 50775 - Balanced Parenthesis
• 50736 - Top N Donors - 2
• 50796 - KNN
• 50340 - Game 19
• 50735 - Top M Products
• 50697 - Base Stations
• 50383 - Noisy Mornings
• 50479 - Bit Compressor
• 50674 - Collecting Eggs
• 50486 - Problems and Programmers
• 50695 - Longest link between neurons
• 50411 - Sum of the Leaves

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

Game 19

Game19, is played with two players. The purpose of the game is to reach 19, first. Both players turn the wheel of fortune 3 times, and sum up the numbers on the wheel.

  • The first player who reaches to 19 wins the game.
  • The first player who exceeds 19 loses the game (thus, the other player wins the game).
  • After 3 turns, if both player are below 19
    • The one who is closer to 19 wins the game.
    • If both are the same then the game is "Draw"

Question: You will be given the order of the numbers on the wheel and 3 moves for both players. Find and show the winner of the game.

Input specification
There is one number (n) at the begining representing the number of numbers on the wheel where 1 ≤ n ≤ 100. On the second line the numbers on the wheel are given which are random numbers from 1 to 10. The first number given is the starting number and the other numbers follow each other on the wheel. And hence, the last is followed by the first number.

Then you are given 2 numbers (ai, bi) in each of the following 3 lines where they represent the moves of the first and the second player from the last position of the wheel and 1 ≤ (ai, bi) ≤ 100

Output specification
On the screen, show

  • "The First" ==> if the first player wins the game
  • "The Second" ==> if the second player wins the game
  • "Draw" ==> if the game is draw.

Sample Input I
  9
  3 9 5 6 4 8 1 7 2
  2 4
  3 3
  4 3
Sample Input II
  6
  7 5 10 5 8 2
  2 2
  10 3
  4 2
Sample Output I
  The Second
Sample Output II
  The Second

Output I Explanation
Player I gets (5+3+7=) 15 and
Player II gets (1+6+9) 16.
Because both players are below 19 and The second player is larger than the other, the winner is the second player.

Output I Explanation
On his first move, Player I goes to 10. Then Player II goes to 8.
On the second move, Player I goes again to 10. Hence, his sum exceeds 19, the game directly finishes and the second player wins the game.
Для отправки решений необходимо выполнить вход.

www.contester.ru