hdu1257

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

#define MAXN 1005

int n;
int dp[MAXN];

int m;

int main()
{
    while(cin>>n)
    {
        int x;
        m = 0;
        memset(dp,0,sizeof(dp));
        for(int i = 1; i <= n; i++)
        {
            cin>>x;
            bool flag = false;
            int j;
            for(j = 1; j <= m; j++)
            {
                if(dp[j] >= x)
                {
                    dp[j] = x;
                    flag = true;
                    break;
                }
            }
            if(!flag)
            {
                dp[++m] = x;
            }
        }
        cout<<m<<endl;
    }
    return 0;
}

你可能感兴趣的:(hdu1257)