a sequence
Published: July 9, 2017 18:17 last update: July 9, 2017 21:05 time limit: 1000ms memory limit: 128M description
If a sequence has an odd number of positive integers, it may be necessary to make this sequence a1,a2,a3,..., a2∗k+1 (0<=k), and a1,a2...ak+1 is a strictly incrementing sequence, ak+1,ak+2,..., a2∗k+1, is a strictly descending sequence, It is said that this sequence is a sequence.
For example, 1 2 5 4 3 is a sequence.
Now Jazz has an array of length n, and he wants you to find out the maximum length of all the sub-sequences in this array that satisfy the definition of a sequence. (sub-sequences can be discontinuous)
For example 1 2 5 4 3 6 7 8 9, the longest a sequence substring is 1 2 5 4 3. Input
Multiple sets of inputs, two rows per group.
The first line is N, which represents the length of the given array.
The second line has n number (int range), which is the array to you.
1<=n<=500000.
Output
Each set of input and output lines, that is, the length of the longest string of a sequence substring. Sample Input 1
9
1 2 5 4 3 6 7 8 9
Sample Output 1
5
#include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <ctype.h> #include <math.h> #include <set> #include <map> #include <vector> #
include<queue> #include <bitset> #include <algorithm> #include <time.h> using namespace std; void Fre () {freopen ("c://test//input.in", "R", stdin), Freopen ("C://test//output.out", "w", stdout), #define MS (x, y) m
Emset (x, y, sizeof (x)) #define LS o<<1 #define RS o<<1|1 typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI; Template <class T1, class t2>inline void Gmax (T1 &a, T2 b) {if (b > a) a = b;} template <class T1, class t2>inline void Gmin (T1 &a, T2 b) {if (b < a) A = b;} const int N = 5e6 + ten, M = 0, Z = 1e9 + 7, I