## Diamonds

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Python 10.0s
Memory limit: 512M
Python 768M

Authors:
Problem type

Bob is playing with a drawing software he recently downloaded. The software loads a by pixel canvas for him to draw on. The pixel at is the -th pixel from the top and the -th pixel from the left, -indexed.

Bob experimented with many tools, but he is really fascinated with the diamond coloring tool.

The diamond tool takes in a pixel location and a weight . It then colors every pixel within a manhattan distance of from . The manhattan distance between two pixels and is .

Bob uses the diamond tool times. Can you determine how many pixels are colored?

Note: Python users should consider not using Python

#### Input Specification

The first line of input will contain .

The next lines will contain space-separated integers , , and .

#### Output Specification

Output one integer on one line, the number of colored pixels.

#### Sample Input

3
2 3 3
8 4 1
4 7 2

#### Sample Output

38

#### Explanation

#####.....
##X####...
########..
.#####X##.
..#..###..
......#...
...#......
..#X#.....
...#......
..........

In the above diagram, the #'s represent colored pixels and X's represent the locations where the diamond tool was used (these are also colored).

Note that this is only a by snippet of the full canvas, but the rest of the canvas is empty. We can count colored pixels.