CF358A.Dima and Continuous Line

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.

The teacher gave Seryozha the coordinates of nn distinct points on the abscissa axis and asked to consecutively connect them by semi-circus in a certain order: first connect the first point with the second one, then connect the second point with the third one, then the third one with the fourth one and so on to the nn -th point. Two points with coordinates (x1,0)(x_{1},0) and (x2,0)(x_{2},0) should be connected by a semi-circle that passes above the abscissa axis with the diameter that coincides with the segment between points. Seryozha needs to find out if the line on the picture intersects itself. For clarifications, see the picture Seryozha showed to Dima (the left picture has self-intersections, the right picture doesn't have any).

Seryozha is not a small boy, so the coordinates of the points can be rather large. Help Dima cope with the problem.

输入格式

The first line contains a single integer nn (1<=n<=103)(1<=n<=10^{3}) . The second line contains nn distinct integers x1,x2,...,xnx_{1},x_{2},...,x_{n} (106<=xi<=106)(-10^{6}<=x_{i}<=10^{6}) — the ii -th point has coordinates (xi,0)(x_{i},0) . The points are not necessarily sorted by their xx coordinate.

输出格式

In the single line print "yes" (without the quotes), if the line has self-intersections. Otherwise, print "no" (without the quotes).

输入输出样例

  • 输入#1

    4
    0 10 5 15
    

    输出#1

    yes
    
  • 输入#2

    4
    0 15 5 10
    

    输出#2

    no
    

说明/提示

The first test from the statement is on the picture to the left, the second test is on the picture to the right.

首页