Sinchon Defense Headquarters
Time limit1.5sMemory limit1024 MB
Given N missile points, count the lattice points that lie in the convex hull of the missiles (including boundary) but are not shield locations.
- Level
Hard9 of 10
- Topics
- Geometry, Math, Sorting, Implementation
- Solved
- No attempts yet
Problem

In a peaceful forest near Sinchon, one tree is planted at every lattice point, as in the picture below. The organizers liked this forest, so they decided to gather people here and hold the ICPC Sinchon Camp.

So on August 21, 2021, the ICPC Sinchon Camp Contest was held in the forest, breathing the fresh air. Just as the contest was about to proceed peacefully, an unidentified organization suddenly began attacking the forest. Missiles are falling on distinct locations in the Sinchon forest. To minimize the damage from the missiles, the ICPC Sinchon organizers installed shields on trees throughout the forest.

The trees with shields installed were unharmed, but due to interactions between the missiles, several trees without shields were burning, as in the picture. Let the coordinates of a tree without a shield be , and let the coordinates of the point where the -th missile fell be . If there exist satisfying the following conditions, that tree burns.
- ()
The organizers are going to mobilize firefighting helicopters to quickly extinguish the fire and rescue the people. However, if too much water is loaded onto a firefighting helicopter, its movement speed becomes slow, so they will load an appropriate amount of water to extinguish the fire. To find the appropriate amount of water, the number of burning trees must be computed exactly. Given the coordinates of the points where the missiles fell, find the number of burning trees.
Input
The first line gives the number of falling missiles and the number of installed shields . ()
From the second line through the -th line, the -coordinate and -coordinate of the location where each missile fell are given. Each coordinate value is an integer between and inclusive, and the locations where the missiles fell are all distinct.
From line through lines, the -coordinate and -coordinate of the location where each shield is installed are given. Each coordinate value is an integer between and inclusive, and the locations where the shields are installed are all distinct.
Output
Output the number of burning trees.