Maximum Increase CodeForces

来源:互联网 发布:湖南卫视杜海涛知乎 编辑:程序博客网 时间:2024/06/12 22:47

You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.

A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarraystrictly greater than previous.

Input

The first line contains single positive integer n (1 ≤ n ≤ 105) — the number of integers.

The second line contains n positive integersa1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print the maximum length of an increasing subarray of the given array.

Example
Input
51 7 2 11 15
Output
3
Input
6100 100 100 100 100 100
Output
1
Input
31 2 3
Output
3
这道题只需要记录前一个数字和当前数字,是不是保持一种增加的关系,就好了,因为他要相邻。
#include <iostream>#include<stdio.h>#include<string.h>#include<algorithm>#define INF 0x3f3f3f3fusing namespace std;const int maxn=1e5+10;int val[maxn];int dp[maxn];int main(){   int n;   scanf("%d",&n);   int ans=0;   for(int i=1;i<=n;i++)   {       dp[i]=1;       scanf("%d",&val[i]);       if(i!=1)         dp[i]=val[i]>val[i-1]?dp[i-1]+1:dp[i];        ans=max(ans,dp[i]);   }   printf("%d\n",ans);    return 0;}