上升的子串 (长沙理工大学第十一届程序设计竞赛)

来源:互联网 发布:广州google seo 编辑:程序博客网 时间:2024/04/28 11:48

上升的子串

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

62 2 1 3 4 132 2 9

Sample Output

32

Statistic | Submit | Back

#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;}


0 0
原创粉丝点击