zoukankan      html  css  js  c++  java
  • codeforces 702A A. Maximum Increase(水题)

    题目链接:

    A. Maximum Increase

    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Input

    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).

    Output

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

    Examples
    input
    5
    1 7 2 11 15
    output
    3
    input
    6
    100 100 100 100 100 100
    output
    1
    input
    3
    1 2 3
    output
    3

    题意:

    求最长的上升子串;

    思路:

    水题;

    AC代码:

    /************************************************ 
    ┆  ┏┓   ┏┓ ┆    
    ┆┏┛┻━━━┛┻┓ ┆ 
    ┆┃       ┃ ┆ 
    ┆┃   ━   ┃ ┆ 
    ┆┃ ┳┛ ┗┳ ┃ ┆ 
    ┆┃       ┃ ┆  
    ┆┃   ┻   ┃ ┆ 
    ┆┗━┓    ┏━┛ ┆ 
    ┆  ┃    ┃  ┆       
    ┆  ┃    ┗━━━┓ ┆ 
    ┆  ┃  AC代马   ┣┓┆ 
    ┆  ┃           ┏┛┆ 
    ┆  ┗┓┓┏━┳┓┏┛ ┆ 
    ┆   ┃┫┫ ┃┫┫ ┆ 
    ┆   ┗┻┛ ┗┻┛ ┆       
    ************************************************ */  
    
    
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <bits/stdc++.h>
    #include <stack>
    
    using namespace std;
    
    #define For(i,j,n) for(int i=j;i<=n;i++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
    
    typedef  long long LL;
    
    template<class T> void read(T&num) {
        char CH; bool F=false;
        for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar('
    ');
    }
    
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=1e9;
    const int N=1e5+10;
    const int maxn=(1<<8);
    const double eps=1e-8;
    
    int a[N],g[N],d[N];
    int main()
    {       
            int n;
            read(n);
            For(i,1,n)read(a[i]);
            int ans=1,temp=1;
            For(i,2,n)
            {
                if(a[i]>a[i-1])temp++;
                else 
                {
                    ans=max(ans,temp);
                    temp=1;
                }
            }
            ans=max(ans,temp);
            /*
            For(i,1,n)
            {
                int k=lower_bound(g+1,g+n+1,a[i])-g;
                d[i]=k;
                g[k]=a[i];
            }
            cout<<d[n]<<endl;*/
            cout<<ans<<endl;
            
            return 0;
    }
    

      

  • 相关阅读:
    CF785CAnton and Permutation(分块 动态逆序对)
    Codeforces617E XOR and Favorite Number(分块 异或)
    POJ2155 Matrix(二维树状数组||区间修改单点查询)
    阿里云重磅发布数据库专家服务
    Dataphin公共云重磅发布,提供一站式智能数据构建与管理能
    阿里大数据产品Dataphin上线公共云,将助力更多企业构建数据中台
    快速完成智能数据构建,Dataphin公共云版本全面解读
    微服务开源生态报告 No.1
    分享 KubeCon 2019 (上海)关于 Serverless 及 Knative 相关演讲会议
    MaxCompute 费用暴涨之存储压缩率降低导致SQL输入量变大
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5720262.html
Copyright © 2011-2022 走看看