Picky Eater
Time limit1sMemory limit512 MB
Cut the convex polygon along one diagonal between nonadjacent vertices and eat the largest piece that contains no olive.
- Level
Medium6 of 10
- Topics
- Geometry, Brute force, Prefix sum
- Solved
- No attempts yet
Problem
Byeongchan ordered a pizza for his friend Gongchan. Gongchan dislikes olives, so he wants to cut the pizza before eating it.
The pizza is a convex polygon and the olives are stuck inside it. Gongchan picks two vertices that are not adjacent and cuts the pizza once along the straight line through those two vertices. The cut leaves two pieces, and Gongchan eats the piece that holds no olive. If an olive sits on the cutting line, that olive is split in two, so he can eat neither piece.
Byeongchan does not eat much pizza, so Gongchan wants the piece he eats to be as large as possible. Write a program that finds how large a piece Gongchan can cut for himself.
Input
The first line contains the number of pizza vertices .
Each of the next lines contains the coordinates , of one vertex. The vertices are given counterclockwise, and all interior angles of the pizza are smaller than 180 degrees.
Line contains the number of olives .
Each of the next lines contains the coordinates , of one olive. No olive lies on an edge of the pizza or outside the pizza. An olive is tiny, so treat it as a point.
Output
If Gongchan gets no edible piece no matter how he cuts, print 0.
Otherwise print twice the largest area Gongchan can eat. Think it through and you will see that this value is always an integer.
Constraints
All coordinates are integers between and . The pizza is a convex polygon, so .