zoukankan      html  css  js  c++  java
  • cf702A 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

    求出最长上升子串长度

    真是逗逼。。写了<和>的情况忘记搞=了

    然后被x。。

    幸好不记分

    哎毕竟是老了

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<algorithm>
     5 #include<cmath>
     6 #include<set>
     7 #include<map>
     8 #include<ctime>
     9 #define LL long long
    10 #define inf 0x7ffffff
    11 #define pa pair<int,int>
    12 #define pi 3.1415926535897932384626433832795028841971
    13 using namespace std;
    14 inline LL read()
    15 {
    16     LL x=0,f=1;char ch=getchar();
    17     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    18     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    19     return x*f;
    20 }
    21 inline void write(LL a)
    22 {
    23     if (a<0){printf("-");a=-a;}
    24     if (a>=10)write(a/10);
    25     putchar(a%10+'0');
    26 }
    27 inline void writeln(LL a){write(a);printf("
    ");}
    28 int n,x,tot,ans;
    29 int a[100010];
    30 int main()
    31 {
    32     n=read();
    33     for(int i=1;i<=n;i++)a[i]=read();
    34     x=a[1];tot=1;ans=1;
    35     for (int i=2;i<=n;i++)
    36     {
    37         if (a[i]>x)x=a[i],tot++;
    38         else if (a[i]<=x)x=a[i],tot=1;
    39         ans=max(ans,tot);
    40     }
    41     printf("%d
    ",ans);
    42 }
    cf702A
    ——by zhber,转载请注明来源
  • 相关阅读:
    用友软件T3出纳通提示单据锁定
    保存单据时提示“计量单位组不正确”
    cxgrid导出数据的格式设置(转载)
    会话打印机不会自动删除解决方法
    用友U8总账对账不平问题总结
    存货核算期初无法从库存取数
    SQL Server 2000 数据库日志太大!如何管理,清除,变小,压缩它
    Delphi控件cxGrid 如何动态创建列?
    关于Treeview 选中节点高亮有关问题
    U8远程接入客户端重新安装问题
  • 原文地址:https://www.cnblogs.com/zhber/p/5742902.html
Copyright © 2011-2022 走看看