DWITE Online Computer Programming Contest, December 2007, Problem 4
The world renowned mathematician, Dr. J.R.R "Bob" Dobbs, has collected rocks for years, and has built up quite a substantial collection, which he keeps scattered throughout his backyard. Unfortunately, after an interview with the local newspaper, thieves have been trying to steal his precious stones, and so Dr. Dobbs has called the Convex Fence Company to build a fence around them for him.
His instructions to the Convex Fence Company were very precise. Being very proud of his collection, he's instructed that the Convex Fence Company make sure that no matter where he's standing in his yard, the fence doesn't block the view. Below is an example of a possible fence.
The above fence has five sections. The Convex Fence Company sells their fence by the meter, and so charges the client for a full meter even if they only use a portion of one for a section. That is to say, if the above sections were
Given that fence costs
The following format will be repeated five times within the file, each time describing a different setup of rocks in Mr. Dobbs' backyard:
Line
Line
Line
The output will contain 5 lines, a formatted string per line — the cost to fence Mr. Dobbs' rocks.
Note: the formatted string for the output is in the form $abc.00
.
Sample Input
4
5
1 1
4 1
1 4
2 2
Sample Output
$55.00
Problem Resource: DWITE
Comments
In case anyone else is having the trouble I had with
and 
. If 
the answer is 
the answer is 2 times the distance between the two points. Don't think that sharing this information violates any rules and the question failed to specify for those cases.
$0.00
and if