一本通 1281:最长上升子序列

最长上升子序列

#include 
#include 
using namespace std;
//Mystery_Sky
//最长上升子序列 
#define M 1010
int f[M], a[M], n;
int ans;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), f[i] = 1;
    for(int i = 2; i <= n; i++)
        for(int j = 1; j < i; j++)
            if(a[i] > a[j]) f[i] = max(f[i], f[j]+1);
    for(int i = 1; i <= n; i++) ans = max(ans, f[i]);
    return 0 * printf("%d\n", ans);
}

转载于:https://www.cnblogs.com/Benjamin-cpp/p/10786414.html

你可能感兴趣的:(一本通 1281:最长上升子序列)