You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
545 B
C++

#include <cstdio>
#include <algorithm>
using namespace std;
int n,p[1005];
int main()
{
scanf("%d",&n);
for(int i=0; i<n; i++)
scanf("%d",p+i);
for(int i = 0; i < n-1; i++)
for(int j = i+1; j < n-1; j++)
{
int a = min(p[i],p[i+1]);
int b = max(p[i],p[i+1]);
int c = min(p[j],p[j+1]);
int d = max(p[j],p[j+1]);
if((c>a&&c<b&&d>b)||(d>a&&d<b&&c<a))
return puts("yes"),0;
}
puts("no");
return 0;
}