Codeforces Round #208 (Div. 2) A.Dima and Continuous Line

OpenSoucre發表於2013-10-28
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <vector>
 4 
 5 using namespace std;
 6 
 7 int check(int a, int b){
 8     if(a - b > 0 )return 1;
 9     else if(a-b < 0) return -1;
10     else return 0;
11 }
12 
13 int main(){
14     int n;
15     cin >> n;
16     vector<int> x(n);
17     for(int i = 0; i < n; ++ i) cin >> x[i];
18     int i;
19     for( i = 3; i < n ; ++ i){
20         int j ;
21         for(j = 0 ; j < i-1; j ++){
22             int a = check(x[j],x[i-1]);
23             int b = check(x[j],x[i]);
24             int c = check(x[j+1],x[i-1]);
25             int d = check(x[j+1],x[i]);
26             if(a*b*c*d < 0){
27                 cout<<"yes"<<endl;
28                 break;
29             }
30         }
31         if(j < i-1) break;
32     }
33     if(i >= n) cout<<"no"<<endl;
34 }

 

相關文章