题目链接:http://codeforces.com/problemset/problem/702/A点击打开链接
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 subarray strictly greater than previous.
The first line contains single positive integer n (1 ≤ n ≤ 105) — the number of integers.
The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).
Print the maximum length of an increasing subarray of the given array.
5 1 7 2 11 15
3
6 100 100 100 100 100 100
1
3 1 2 3
3
最长严格递增子串 跟求最大区间和很像 dp[i]记录以i结尾的上升的最长子串个数
因为连续的所以很好找到递推方程
#include <iostream>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
#include <limits.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#define maxn 101000
using namespace std;
int dp[maxn];
int a[maxn];
int main()
{
int n=0;
int maxx=1;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
dp[1]=1;
for(int i=2;i<=n;i++)
{
if(a[i]>a[i-1])
dp[i]=dp[i-1]+1;
else
dp[i]=1;
maxx=max(maxx,dp[i]);
}
printf("%d",maxx);
}