#P2116. Minimum Wall Length around the Castle
Minimum Wall Length around the Castle
Minimum Wall Length around the Castle
A greedy king once ordered his knights to build a wall around his castle such that the wall is never closer than a distance \(L\) from the castle. The castle is a polygon with \(n\) sides. The king, being very stingy, does not want to build even one meter extra in length; if more is built, the knight responsible will be executed.
Your task is to help the unfortunate knight compute the minimum length of wall that must be built. For a polygon castle, the minimum wall is exactly the offset of the castle by a distance \(L\). It can be shown that the minimum length of the wall is equal to the sum of the perimeter \(P\) of the castle and \(2\pi L\). That is, the answer is given by:
[ \text{Answer} = P + 2\pi L, ]
where \(P\) is the perimeter of the castle. The answer should be rounded to the nearest integer (use conventional rounding, i.e. round half up).
inputFormat
The input begins with a line containing two integers \(n\) and \(L\):
- \(n\) (\(3 \le n \le 1000\)) is the number of vertices of the castle.
- \(L\) (\(0 \le L \le 10000\)) is the minimum distance from the castle to the wall.
Then follow \(n\) lines, each containing two integers \(x\) and \(y\) (\(|x|,|y| \le 10000\)), which represent the coordinates of the vertices of the castle in either clockwise or counter-clockwise order. The castle is a simple polygon.
outputFormat
Output the minimum length of the wall required, rounded to the nearest integer.
sample
3 1
0 0
3 0
0 4
18