## Editorial for CCC '21 S1 - Crazy Fencing

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**Author:

Observe that each fence piece is a trapezoid. We can loop through adjacent pairs of heights and use the width to calculate the area of each fence piece. The answer is the sum of areas of all fence pieces.

There are many ways to avoid precision issues with the problem, but one of them is to store (which is guaranteed to be an integer) instead and divide by at the end, printing `.5`

if necessary.

**Time Complexity:**

## Comments