上升的子串

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other)
Total Submission(s) : 18   Accepted Submission(s) : 6

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem Description

ElemenT喜欢单调上升的子串,子串的含义是数列中一段连续的数。
如今有一个数列,ElemenT想知道这个数列中,最长的的单调上升子串有多长。

Input

多组数据,对于每组数据首先输入一个正整数N代表数列的长度。


接下来一行输入N个数。两个数之前用空格隔开。


N < 100000。 数列中的数不超过1000000000。

Output

对于每组数据,输出一个数表示最长的单调上升子串的长度。

Sample Input

6
2 2 1 3 4 1
3
2 2 9

Sample Output

3
2


#include <stdio.h>
int a[100005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
        int count=0;
        int max=0;
        for(int i=1;i<n;i++)
        {
            if(a[i]>a[i-1])
            count++;
            else
            count=0;
            if(count>max)
            max=count;
        }
        printf("%d\n",max+1);
    }
    return 0;
}