This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
using namespace std;
/*
知识点内容:最长上升子序列
文档内容参考:
https://www.cnblogs.com/aiguona/p/7278141.html
*/
int main() {
int n, i, j, num, h[1000], max[1000];
while (~scanf("%d", &n)) {
num = 1;
for (i = 0; i < n; ++i) {
scanf("%d", &h[i]);
max[i] = 1;
}
for (i = 1; i < n; ++i)/*求最长上升子序列*/
for (j = 0; j < i; ++j) {
/*用两个数组,方便理解,如果只是求最长上升子序列,可以直接max[j]和num比较取较大值*/
if (h[j] < h[i] && max[j] + 1 > max[i])
max[i] = max[j] + 1;
if (num < max[i])
num = max[i];
printf("%d\n", num);
return 0;