Gahui the Grappler!!
InterviewTime limit2sMemory limit512 MB
Given a piecewise linear function through points (i, y_i) with y_0=0, decide whether the ray y=kx meets it anywhere besides the origin.
- Level
Medium5 of 10
- Topics
- Geometry, Math, Implementation, Binary search
- Solved
- No attempts yet
Problem
This problem is about graphs.
Let and (where ). Jo Gahui carried out the following to draw a function defined on the interval .
for(int i=1;i<=n;i++)
Draw a line segment connecting (i-1,arr[i-1].y) and (i,arr[i].y).
For example, let and .

In this case, the function is drawn as in the figure above. Jo Gahui wonders whether the functions and , both defined on the interval , meet at any point other than . Please satisfy her curiosity.
Input
The first line gives the integer . The second line gives numbers. The third line gives . , and every number other than is an integer greater than or equal to and less than or equal to .
Output
Print T if the two meet at a point other than , and F otherwise.