zoukankan      html  css  js  c++  java
  • 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
    ",ans);
        return 0;
    }
  • 相关阅读:
    11
    961. N-Repeated Element in Size 2N Array
    用numpy.pad()对图像进行填充及简单的图像处理
    709. To Lower Case
    929. Unique Email Addresses
    771. Jewels and Stones
    谭凯---访谈录
    如何拍照
    主题阅读法
    社会各职业工作重心和流程
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5802878.html
Copyright © 2011-2022 走看看