AOJ Volume0-0033

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0033

#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <algorithm>
using namespace std;

int main ()
{
    int n = 0;
    cin >> n;
    
    for (int i=0; i < n; i++) {
        //入力
        int num[10] = {0};
        for (int j=0; j < 10; j++) {
            cin >> num[j];
        }
        
        vector<int> left,right;
        
        //初期
        left.push_back(num[0]);
        right.push_back(0);
        
        bool flag = false;
        
        for (int j=1; j < 10; j++) {
            if (left[left.size() - 1] > num[j]) {
                if (right[right.size() - 1] > num[j]) {
                    flag = true;
                    break;
                }else {
                    right.push_back(num[j]);
                }
            }else {
                left.push_back(num[j]);
            }
            
        }
        if (flag) {
            cout << "NO" << endl;
        }else {
            cout << "YES" << endl;
        }
    }
    
    return 0;
}
広告を非表示にする