Assign n poles of given heights to a central hole and n-1 fixed holes around it to maximize the total volume of the resulting triangles.
Hard8GeometryDynamic programmingGreedySortingNo attempts yetTime limit2sMemory limit512 MBA circus is putting up its tent. The canvas is held up by n poles of various lengths. The holes for the poles are already dug at fixed spots on the ground, but you decide which pole goes into which hole.
One hole is at the origin and takes the central pole. The other n−1 holes lie around the origin. Take two outer poles that are adjacent in the order of their angle around the origin, together with the central pole: the canvas over those three tops is pulled tight into one flat triangle. Only the space under these triangles counts as volume, and the volume under one triangle is the space trapped between the triangle drawn on the ground and the piece of canvas above it.
Assign the poles to the holes so that the total volume under the tent is as large as possible, and report that volume.
The first line contains an integer n (3≤n≤30), the number of poles.
Each of the next n−1 lines contains two integers x and y (−1000≤x,y≤1000), one hole position on the ground. These lines are not sorted by angle around the origin.
Each of the next n lines contains one integer h (1≤h≤100), the length of one pole.
One pole goes into the hole at the origin, and the remaining n−1 poles go into the listed positions, one pole per hole. The listed positions surround the origin: the polygon whose vertices are those positions, taken in order of angle around the origin, contains the origin strictly inside. No two positions have the same angle at the origin, so no canvas triangle has area 0.
Print the largest total volume under the tent, rounded to exactly two decimal places. The exact answer is always a multiple of 61 and never falls exactly halfway between two two-decimal values, so the rounded number is unique.