/-------------------------------------------------------没什么好说的纯最长上身子序列#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn = 1000+10;int dp[maxn];int num[maxn];int n;int lis(){ int core = 1, ans = 1; dp[1] = 1; for(int i = 2; i <= n; i++){ int core = 0; for(int j = 1; j < i; j++){ if(num[j] < num[i] && dp[j] > core){ core = dp[j]; } } dp[i] = core + 1; if(dp[i] > ans) ans = dp[i]; } return ans;}int main (){ while(scanf("%d", &n) != EOF){ for(int i = 1; i <= n; i++)scanf("%d", &num[i]); cout << lis() << endl; } return 0;}
新闻热点
疑难解答