#include <stdio.h>
int dp[1001];
int num[1001];
int max(int a,int b) {
    return a>b ? a:b;
}
int bottom_up(int n) {
    int res=0;
    for(int i=1; i<=n; i++) {
        dp[i]=1;
        for(int j=1; j<=i-1; j++) {
            if(num[i]<num[j]) {
                dp[i]=max(dp[i],dp[j]+1);
            }
        }
        res=max(dp[i],res);
    }
    return res; 
}

int main() {
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++) {
        scanf("%d",&num[i]);
    }
    printf("%d",bottom_up(n));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: