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;
    }
    

      

  • 相关阅读:
    概要设计
    JNI内存泄露
    Flash 与 JS 交互
    Lucene.net 实现全文搜索(转)
    自动打开登录游戏的代码
    Ajax,网站改版的一种方法
    IE6/IE7和Firefox对Div处理的差异(转)
    搜VC里找到的
    C# 尝试读取或写入受保护的内存。这通常指示其他内存已损坏
    HTML特殊转义字符列表
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5720262.html
Copyright © 2011-2022 走看看