Can be written in two points ...
Base time limit: 1 seconds space limit: 131072 KB score: 0 Difficulty: Basic collection focus on giving an array of length n to find the longest increment subsequence of this array. (incrementing a subsequence means that the elements of the subsequence are incremented) For example: 5 1 6 8 2 4 5 10, the maximum increment subsequence is 1 2 4 5 10. Input
Line 1th: 1 number n,n is the length of the sequence (2 <= N <= 50000) 2-n + 1 lines: 1 numbers per line, elements of the corresponding sequence ( -10^9 <= s[i] <= 10^9)
Output
Outputs the longest increment of the length of a subsequence.
Input example
8516824510
Output example
5
Related issues maximum increment subsequence V2 160 maximum increment subsequence number of the longest ascending sub-series It's very ingenious ... Code:
1#include <cstdio>2#include <cmath>3#include <cstring>4#include <string>5#include <algorithm>6#include <queue>7#include <stack>8#include <map>9#include <Set>Ten#include <vector> One#include <iostream> A using namespacestd; - #defineFor0 (i, n) for (int i=0; i< (n); ++i) - #defineFor1 (i,a,n) for (int i= (a); i<= (n); ++i) the #defineFor2 (i,a,n) for (int i= (a);i< (n); ++i) - #defineFor3 (i,a,n) for (int i= (a); i>= (n);-I.) - #defineFor4 (i,a,n) for (int i= (a);i> (n); - #defineCC (i,a) memset (i,a,sizeof (i)) + #defineLL Long Long - #defineMOD 1000000007 + #defineINF 0x3f3f3f3f A #defineMAX 50100 at - intDp[max],num[max]; - intN; - - intMain () - { inscanf"%d",&n); -memset (Dp,inf,sizeof(DP)); tomemset (Num,inf,sizeof(num)); + for(intI=0; i<n; i++) -scanf"%d",&dp[i]); the intPath=0; * for(intI=0; i<n; i++){ $ for(intj=0; j<n; J + +){Panax Notoginseng if(dp[i]<Num[j]) { -num[j]=Dp[i]; the if(path<j) +Path=J; A Break; the } + } - } $printf"%d\n", path+1); $}
1134 Maximum increment subsequence (violent writing)