"Grand Game Cup" 15th Shanghai University Program Design League F "" Lis template problem "a sequence

Source: Internet
Author: User

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 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.