Piecewise Linear Function
InterviewTime limit1sMemory limit1024 MB
Given N points joined by line segments, report for each query x-coordinate k whether the piecewise linear function is increasing, decreasing, or flat there.
- Level
Easy3 of 10
- Topics
- Binary search, Array
- Solved
- No attempts yet
Problem
Points are given on a two-dimensional coordinate plane. The position of the -th point is , and holds for every with . A linear function connecting point and point is drawn. Let be the combination of the linear functions defined on the intervals .
For example, when the points are , , , , and , the drawn function is shown below.

For each query, a real number is given. Determine whether is increasing or decreasing at .
Input
The first line contains the number of points .
From the second line onward, the lines each contain the coordinates separated by a space.
The -th line contains the number of queries .
From the -th line onward, the lines each contain a query .
and are integers. Each is given with at most one digit after the decimal point.
Output
For each query, print if the linear function containing is increasing, if it is decreasing, and if it is neither. Print one answer per line, in query order.