Piecewise Linearity
Time limit1sMemory limit512 MB
Decide whether a piecewise linear function given by n+1 increasing x-coordinates can be written as a real linear combination of absolute value terms |x - a_i|.
- Level
Hard8 of 10
- Topics
- Math, Geometry, Implementation
- Solved
- No attempts yet
Problem
Alice is obsessed with linear functions and especially their plots that are always so mysteriously straight. Recently she found out a plot of function that impressed her a lot: it was twice as mysterious and beautiful since it consisted not only of one straight-line segment, but of two of them!
Alice immediately thought of a function that is times as mysterious as a linear function. Formally, she came up with a piecewise linear function , whose plot consists of straight-line segments. Function is defined by points belonging to its plot and allowing to reconstruct it in a following manner. Plot of function is a polyline consisting of two rays , and line segments , , . Each point is defined by its Cartesian coordinates , which are both integers. It is guaranteed that for all between and , i.e. given polyline is a plot of some function . Please, refer to the Note section for more details.
Now Alice asks you if it is possible to express her function as a linear combination of terms of form . Formally, your task is to find out if there exist two finite sequences of real numbers and such that the following equation holds:
Input
First line of input contains an integer (), the number of segments in a polyline that is a plot of Alice function.
In the -th of next lines (indexed from zero) there are two integers , (), coordinates of point .
It is guaranteed that .
Output
If it is possible to express as a linear combination of terms of form , print the only word "Yes" (without quotes). Otherwise print the only word "No" (without quotes).
Note
Pictures for the sample cases are given below:


