LIS和LDS模板:
const int MAXN = 100005;
int a[MAXN], dp[MAXN];

//最长上升子序列
int LIS(int n)
{
    int res = 0;

    for(int i = 0; i < n; ++i)
    {
        dp[i] = 1;
        for(int j = 0; j < i; ++j)
            if(a[j] < a[i]) dp[i] = max(dp[i], dp[j]+1);
        res = max(res, dp[i]);
    }
    return res;
}
//最长下降子序列
int LDS(int n)
{
    int res = 0;

    for(int i = 0; i < n; ++i)
    {
        dp[i] = 1;
        for(int j = 0; j < i; ++j)
            if(a[j] > a[i]) dp[i] = max(dp[i], dp[j] + 1);
        res = max(res, dp[i]);
    }
    return res;
}