Under construction

Still being built. Things may change

Piecewise Linearity

Time limit1sMemory limit512 MB

Summary
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 f(x)=∣x−1∣f(x) = |x-1| 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 n≥2n \geq 2 times as mysterious as a linear function. Formally, she came up with a piecewise linear function f(x)f(x), whose plot consists of nn straight-line segments. Function f(x)f(x) is defined by n+1n+1 points P0,P1,…,Pn−1,PnP_0, P_1, \ldots, P_{n-1}, P_n belonging to its plot and allowing to reconstruct it in a following manner. Plot of function f(x)f(x) is a polyline consisting of two rays P1P0P_1 P_0, Pn−1PnP_{n-1} P_n and n−2n-2 line segments P1P2P_1 P_2, …\ldots, Pn−2Pn−1P_{n-2} P_{n-1}. Each point PiP_i is defined by its Cartesian coordinates (xi,yi)(x_i, y_i), which are both integers. It is guaranteed that xi>xi−1x_i > x_{i-1} for all ii between 11 and nn, i.e. given polyline is a plot of some function f(x)f(x). Please, refer to the Note section for more details.

Now Alice asks you if it is possible to express her function f(x)f(x) as a linear combination of terms of form ∣x−ai∣|x - a_i|. Formally, your task is to find out if there exist two finite sequences of real numbers λ1,λ2,…,λm\lambda_1, \lambda_2, \ldots, \lambda_m and a1,a2,…,ama_1, a_2, \ldots, a_m such that the following equation holds:

f(x)=∑i=1mλi∣x−ai∣f(x) = \sum\limits_{i=1}^m \lambda_i |x - a_i|

Input

First line of input contains an integer nn (2≤n≤100 0002 \leq n \leq 100\,000), the number of segments in a polyline that is a plot of Alice function.

In the ii-th of next n+1n+1 lines (indexed from zero) there are two integers xix_i, yiy_i (−106≤xi,yi≤106-10^6 \leq x_i, y_i \leq 10^6), coordinates of point PiP_i.

It is guaranteed that x0<x1<…<xnx_0 < x_1 < \ldots < x_n.

Output

If it is possible to express f(x)f(x) as a linear combination of terms of form ∣x−ai∣|x - a_i|, print the only word "Yes" (without quotes). Otherwise print the only word "No" (without quotes).

Note

Pictures for the sample cases are given below:

Examples3

  1. Example 1

    Input
    2
    -1 2
    1 0
    2 1
    
    Expected output
    Yes
    
  2. Example 2

    Input
    3
    -3 -1
    -1 -1
    1 1
    4 1
    
    Expected output
    Yes
    
  3. Example 3

    Input
    3
    -3 1
    -2 0
    0 1
    1 1
    
    Expected output
    No