#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
int n, demo[2222];
int dp[2222],temp;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &demo[i]);
ms(dp, INF);
for (int i = 0; i < n; i++) {
temp = i;
for (int j = 0; j < i; j++)
if (demo[i] <= dp[j] && dp[j] < dp[temp])
temp = j;
if (temp == i)
dp[i] = demo[i];
else
dp[temp] = demo[i];
}
int ans = 0;
for (int i = 0; i < n; i++)
if (dp[i] != INF) ans++;
printf("%d\n", ans);
return 0;
}
来源:CSDN
作者:Fawkess
链接:https://blog.csdn.net/Fawkess/article/details/103246358