Treasure Hunt
Time limit10sMemory limit256 MB
Find the most treasures a single straight line can place on the opposite side from all mines.
- Level
Medium7 of 10
- Topics
- Geometry, Brute force
- Solved
- No attempts yet
Problem
An island holds buried treasures and buried mines. Disarming the mines one at a time is far too dangerous, so you build a single straight fence instead, separating the ground that holds the mines from the ground where the treasure hunt runs.
The fence is a straight line with no thickness that extends forever in both directions, and the island counts as convex. The fence splits the island into two sides, and only the treasures on a side with no mine can be collected safely. No treasure and no mine may lie on the fence itself.
Find the largest number of treasures you can put on a mine free side with one fence.
Input
The first line contains the number of test cases .
The first line of each test case contains the number of treasures and the number of mines . Two lines follow, each with integers. The -th integer on the first line is the coordinate of the -th treasure, and the -th integer on the second line is its coordinate. Two more lines follow, each with integers, giving the and coordinates of the mines in the same way.
- every coordinate is an integer with
- no two objects share a position
- no treasure and no mine lies on the fence
Output
For each test case, print on one line the largest number of treasures that a single fence can separate from every mine. Print 0 if no treasure can be separated.