编辑代码

#include <iostream>
using namespace std;
int pos = 0,n;
int cnt[5141];
int main() {
    cin>>n;
    for(int i= 1;i <= n;i++)
    {
        int h;
        cin>>h;
        bool flag = 0;
        for(int j = 1;j <= pos;j++)
        {
            if(cnt[j] >= h)
            {
                cnt[j] = h;
                flag = 1;
                break;
            }
        }
        if(flag == 0)
        {
            pos++;
            cnt[pos] = h;
        }
    }

    cout<<pos<<endl;
	return 0;
}