Problem B
Triangle Containment
You recently discovered there is treasure buried on your farm land. A lot of treasure! You quickly decide to put a fence around the land.
Alas, you have but a single fence post! You will have to drive to town to get more fencing material. But you can’t just leave the land as open as it is, so you decide to create a makeshift fence to protect some of the treasure while you are gone. You will place the post in the ground and run some wire in a straight line between two sides of your barn wall and the fence post to section off a triangular area. Also, the ground is very hard: only places that were dug up to bury a treasure are soft enough for you to quickly place the fence post.
To figure out the best option, you first calculate the following. For each of the treasures in your field, if you were to place the fence post at that treasure and complete the fence as described, then what is the total value of all treasures that would be enclosed by the fence? Note that the treasure under the post you place is not considered enclosed by the fence (it might not be safe since someone could dig around the post).
Sample Input 1 is illustrated below. The triangle that
includes the point
![\includegraphics[width=0.4\textwidth ]{triangle.pdf}](/problems/trianglecontainment/file/statement/en/img-0001.png)
Input
The first line of input contains two integers
Each of the next
Output
Output
Sample Input 1 | Sample Output 1 |
---|---|
5 8 -8 1 1 -1 10 2 0 3 4 7 1 8 8 2 16 |
0 12 0 0 8 |
Sample Input 2 | Sample Output 2 |
---|---|
6 6 0 1 1 2 3 10 2 5 100 3 1 1000 3 5 10000 4 5 100000 |
0 1000 1010 0 1010 1000 |