[Coding Club of MU] 2020-11-12


2020-11-12 08:17 AKST

[Coding Club of MU] 2020-11-12


2020-11-19 08:17 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -72 days 17:13:18

Time elapsed


Time remaining


Problem G

Source: pixabay

In a game of American Football, there are several factors to take into consideration when detailing the rules of the game. The goal of the game is to move the football across the field into the endzone of the defending team through a series of plays, which form a drive. In each play, the attacking team may either gain or lose a number of yards, that is, their position on the field moves either towards or away from the defending team’s endzone.

In the simplified version of football that we consider, a team has four chances (in up to four plays) to advance the ball $10$ yards downfield; if they are successful, they will have achieved a “first down” and keep possession of the ball. If they achieve a first down, they have another up to four plays to continue their drive towards the defending team’s endzone. If they keep possession and reach the defending team’s endzone, they will have achieved a Touchdown. If they are pushed back into their own endzone, a Safety occurs and ends the drive. Otherwise the team loses possession of the ball and Nothing happens.

Sadly, the outcome of a drive has been lost, and all that remains is the yards gained or lost on each play! Your job is to determine whether a Touchdown, Safety, or Nothing occurred on the given drive.

For simplicity, we assume that the team starts the drive on their own $20$ yard line on a $100$ yard field (with $0$ being the team’s own endzone, and $100$ being the defending team’s endzone). This means that a touchdown is scored if at least $80$ yards are gained in total, relative to the starting position, and without losing possession due to failing to get a first down. Note that it is possible for a team to score a Touchdown without getting a first down. A safety occurs if the team is pushed back $20$ yards from their original starting position, which would place them in their own endzone. Nothing occurs if neither of these events occurs.


The input starts of a line containing one integer $N$ ($1 \le N \le 15$), which is the number of plays that this given drive recorded. Following this line are $N$ integers representing the numbers of yards gained or lost on each particular play. Each given number is between $-100$ and $100$ yards (exclusive range) since that is the length of the football field.


Output a single word, the result of the drive! If a touchdown is achieved, output “Touchdown”, if a safety is achieved, output “Safety”, else output “Nothing”. (Do not add a period at the end.) Once the outcome has been determined, your program should ignore any remaining yards listed in the drive.

Sample Input 1 Sample Output 1
10 3 8 22 -4 16 8 3 14
Sample Input 2 Sample Output 2
9 15 2 -5 3 8 18 3 25 2