CodeForces 702A Maximum Increase

简单$dp$。

如果$a[i]>a[i-1]$,那么$dp[i]=dp[i-1]+1$。否则,$dp[i]=1$。答案为$dp[i]$中的最大值。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-8;
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
    while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
}

const int maxn=100010;
int a[maxn],dp[maxn],n,ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    dp[1]=1; ans=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]>a[i-1]) dp[i]=dp[i-1]+1;
        else dp[i]=1;
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
    return 0;
}

 

posted @ 2016-08-24 14:38  Fighting_Heart  阅读(149)  评论(0编辑  收藏  举报