P

R

O

G

R

A

M

M

I

N

G

 

C

O

M

P

E

T

I

T

I

O

N

 

Golf

Task #5

Novice

5 Points

Task Description
Tiger the Robot plays a perfect game of golf.  When he hits the golf ball it always goes directly towards the hole on the green, and he always hits exactly the distance that is specified for the club.  Each such action is known as a stroke, and the object of golf is to hit the ball from the tee to the hole in the fewest number of strokes.  Tiger needs a program to select the best combination of clubs to reach the hole in the fewest strokes.  Tiger can carry up to 14 clubs, and the total distance from the tee to any hole ranges from 100 to 600 yards.  Tiger can also play up to 18 holes with the same set of clubs.  Tiger must hit the ball the exact distance to the hole in order for the ball to drop in the hole.

Program Input
The first line of input is the number of clubs (between 1 and 14).  For each club, a line follows specifying the distance (in yards) the club will hit the ball (between 1 and 300).  The next line of input is the number of holes (between 1 and 18).  For each hole, a line follows specifying the distance (in yards) from the tee to the hole (between 100 and 600) and the par for the hole (between 1 and 5).  The notes to the right of the data will not be in the input file. They are provided here for clarification.

10     <- 10 clubs are in Tiger’s bag
250    <- Yardage club 1 can hit the ball
175    <- Yardage club 2 can hit the ball
125    <- Yardage club 3 can hit the ball
75     <- Yardage club 4 can hit the ball
50     <- Yardage club 5 can hit the ball
25     <- Yardage club 6 can hit the ball
10     <- Yardage club 7 can hit the ball
5      <- Yardage club 8 can hit the ball
2      <- Yardage club 9 can hit the ball
1      <- Yardage club 10 can hit the ball
3      <- 3 holes for this golf course
453 5  <- First hole is 403 yards, par 5
133 3  <- Second hole is 133 yards, par 3
350 4  <- Third hole is 350 yards, par 4

Program Output
Print out Tiger’s scorecard for this round of golf.  For each hole, print the hole number, the minimum number of strokes for the hole, the number of strokes above or below par for the hole, the total number of strokes to this point, and the total number of strokes above or below par to this point (see below for an example).  Output the results to an output file.  You must include the scorecard header as shown below.

                          Total      Total
Hole    Strokes    +/-    Strokes    +/-
====    =======    ===    =======    =====
1       5          0      5          0
2       4          +1     9          +1
3       3          -1     12         0