Touchdown!
InterviewTime limit1sMemory limit1024 MB
Given the yards gained or lost on each play of a drive, determine whether the team scores a Touchdown, suffers a Safety, or gets Nothing.
- Level
Easy3 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Background
In a game of American Football, several factors must be considered when detailing the rules. The goal is to move the football across the field into the endzone of the defending team through a series of plays, which together form a drive. In each play, the attacking team may gain or lose yards, so its position moves toward or away from the defending team's endzone.
Rules
In this simplified version, a team has up to four plays to advance the ball 10 yards downfield. If it succeeds, it earns a "first down" and keeps possession. After a first down, the team again has up to four plays to continue toward the defending team's endzone. If the team keeps possession and reaches the defending team's endzone, it scores a Touchdown. If it is pushed back into its own endzone, a Safety occurs and the drive ends. Otherwise the team loses possession and Nothing happens.
Scoring
Assume the team starts the drive on its own 20 yard line on a 100 yard field, where 0 is the team's own endzone and 100 is the defending team's endzone. A Touchdown occurs if the team gains at least 80 yards in total relative to the starting position without losing possession by failing to get a first down. If the team gains 80 yards on the first play, it scores a Touchdown even though it did not get a first down in between. A Safety occurs if the team is pushed back 20 yards from its starting position, which places it in its own endzone. If neither event occurs, the result is Nothing.
Input
The first line contains one integer (), the number of plays recorded in the drive. The next numbers are the yards gained or lost on each play. Each number is between and .
Output
Output one word: Touchdown if a Touchdown is achieved, Safety if a Safety is achieved, or Nothing otherwise. Do not add a period at the end. Once the outcome is determined, ignore the remaining yards in the drive.