### 2010 Canadian Computing Competition, Stage 2

## Day 2, Problem 2: Space Miner

There are `M` (1 ≤ `M` ≤ 1000) planets each with
`v _{i}` (1 ≤

`v`≤ 10000) units of resources and radius

_{i}`r`(1 ≤

_{i}`r`≤ 100).

_{i}Starting from (0,0,0), you travel in straight lines through `N`
(1 ≤ `N` ≤ 1000) waypoints in a specific order.

Whenever you travel within `D`+`r _{i}`
(1 ≤

`D`≤ 50) units from a planet's center, you can mine the planet using your tractor beam retrieving

`v`units of resources. Note that if you are exactly

_{i}`D`units from the surface of the planet, you can mine the planet. If your path takes you through a planet, do not worry, since your spaceship can drill through planets, which makes mining even easier. Also note that you cannot mine the same planet on a subsequent visit.

Give the number of minerals that can be mined on your journey.

### Input

On the first line of input is the number `M`, the number of planets.
On the next `M` lines are five integers describing each of the
`M` planets. These integers are
`x _{i}y_{i}z_{i}v_{i}r_{i}`,
where the planet

`i`is at position (

`x`,

_{i}`y`,

_{i}`z`), (where -1000 ≤

_{i}`x`,

_{i}`y`,

_{i}`z`≤ 1000).

_{i}After the `M` planets, there is line containing the integer
`N`, followed by `N` lines (each with three integers
`x`, `y`, and `z`) describing the points on your route
in order.

The last line of input is the number
`D`, the maximum distance from a planet's surface that your ship can be
and still mine a planet.

### Output

On one line, output the amount of minerals that you can mine on your journey.

### Sample Input

3 10 0 0 1 1 0 10 0 2 1 0 0 10 4 1 3 8 0 0 0 7 0 0 0 9 1

### Sample Output

5

All Submissions

Best Solutions

**Point Value:** 15

**Time Limit:** 2.00s

**Memory Limit:** 256M

**Added:** May 19, 2010

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

SourSpinachon May 15, 2013 - 4:42:05 pm UTC CorrectionAfter the M planets, there's a line with the integer N, followed by N lines (each with 3 integers, x, y, and z) describing the points on your route in order.

bbi5291on May 15, 2013 - 5:26:06 pm UTC Re: CorrectionSourSpinachon May 16, 2013 - 12:43:13 am UTC Re: Re: Correctionbbi5291on May 17, 2013 - 10:07:24 pm UTC Re: Re: CorrectionImbaCalvinon May 15, 2013 - 2:53:50 pm UTC Input description error...