UVa514

#pragma warning(disable:4996)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include   
#include 
#include  
#include
#include
#include
#include


using namespace std;

int temp[50000];
int t1[50000];
int t2[50000];

int n;

bool cmp(int* t1, int *t2,int k)
{
    for (int i = 0;i < k;i++)
    {
        if (t1[i] != t2[i])
            return false;
    }
    return true;
}

int cmp1(int a,int b)
{
    return a > b;
}

void copy(int*t2, int *t1, int k)
{
    for (int i = 0;i < k;i++)
    {
        t2[i] = t1[i];
    }
}
void chk()
{
    for (int i = 0;i < n;i++)
    {
        int k = 0;
        for (int j = i + 1;j < n;j++)
        {
            if (temp[i] > temp[j])
            {
                t1[k++] = temp[j];
            }
        }
        copy(t2, t1,k);
        sort(t2, t2 + k,cmp1);
        if (cmp(t2, t1,k)==false)
        {
            cout << "No" << endl;
            return;
        }
    }
        cout << "Yes" << endl;
    return;
}

int main()
{
    while (cin >> n, n)
    {
        while (cin >> temp[0],temp[0])
        {
            for (int i = 1;i < n;i++)
                cin >> temp[i];
            chk();
        }
        cout << endl;
    }
    return 0;
}

你可能感兴趣的:(UVa514)