Younger Sibling of a Right Triangle
InterviewTime limit3sMemory limit1024 MB
For each query (a, b), count the black points inside or on the boundary of the triangle with vertices (0, 0), (a, b), and (a, 0).
- Level
Medium6 of 10
- Topics
- Geometry, Sorting, Prefix sum
- Solved
- No attempts yet
Problem
A voice actor deeply moved by the post "The younger sibling of a right triangle is also a right triangle!" decided to write a problem about right triangles. The problem is as follows.
There are black points on a two-dimensional plane. The and coordinates of all these points are positive. You must answer queries.
- For each query point , count the black points inside the triangle whose vertices are , , and . Points on the boundary of the triangle count as inside the triangle.
The voice actor found it too tedious to work out a solution and fell asleep. Solve the problem for them!
Input
The first line contains the number of points .
The next lines each contain two integers and , separated by a space, the coordinates of a black point. All black points have distinct coordinates.
The next line contains the number of queries .
The next lines each contain two integers and , separated by a space.
Output
Print lines. On the -th line, print the answer to the -th query.