You need some parts manufactured for your zombie protection suit. These
parts are made of steel, and steel can not be cut in your laser CNC.
Unfortunately most of the craftsmen have already left the city. The ones
you can still contact are old fashioned guys, following all the good
tradition: they do not work from CAD files but from printouts. No problem,
you can print all your drawings - as long as you have ink in your printer.
The zombie apocalypse reveals a lot of suboptimal system features in all the software and hardware around you, and your CAD program is not an exception. You need to hatch (fill using parallel lines) large polygons on those drawings, but your CAD system does not optimize the hatch pattern for saving ink. You obviously can not afford wasting ink like that!
You are given a number of polygons, that make up your drawing. Only adjacent sides of a polygon touch, and the circumference of different polygons never intersects. These polygons separate the plane into shapes and holes: the outermost polygons are shapes, the ones contained immediately in these are holes, the polygons inside those are again shapes, and so on.
Your CAD program will hatch the shapes (but not the holes) with horizontal lines of distance D. (Horizontal means parallel to the x axis.) If a side of a polygon is horizontal, the program will not draw a hatch line over it. If a hatch line touches a vertex of the polygon, it still counts as one line.
Your task is to optimize the offset of these lines to minimize total number of hatch lines.
2 10 3 0 0 50 10 0 46 3 20 20 5 8 10 6