Problem description

Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence ai. Let us remind you that the subsegment of the sequence is its continuous fragment. A subsegment of numbers is called non-decreasing if all numbers in it follow in the non-decreasing order.

Help Kefa cope with this task!

Input

The first line contains integer n (1 ≤ n ≤ 105).

The second line contains n integers a1,  a2,  ...,  an (1 ≤ ai ≤ 109).

Output

Print a single integer — the length of the maximum non-decreasing subsegment of sequence a.

Examples

Input

6
2 2 1 3 4 1

Output

3

Input

3
2 2 9

Output

3

Note

In the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.

In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one.

解题思路:求最大非递减序列的长度,注意maxlen初始值为1,水过!

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int n,len=,maxlen=,a[];
int main(){
cin>>n;
for(int i=;i<n;++i)cin>>a[i];
for(int i=;i<n;++i){
if(a[i]>=a[i-])len++;
else len=;
maxlen=max(maxlen,len);
}
cout<<maxlen<<endl;
return ;
}

A - Kefa and First Steps的更多相关文章

  1. Codeforces Round #321 (Div. 2) A. Kefa and First Steps 水题

    A. Kefa and First Steps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/58 ...

  2. Codeforces 580A - Kefa and First Steps

    580A - Kefa and First Steps 思路:dp dp[i]表示包括前i个元素中a[i]在内的最大增序列. 代码: #include<bits/stdc++.h> usi ...

  3. Codeforces Round #321 (Div. 2) A. Kefa and First Steps【暴力/dp/最长不递减子序列】

    A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. Codeforces Round #321 (Div. 2)-A. Kefa and First Steps,暴力水过~~

    A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  5. codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/580/A题意:求最长连续非降子序列的长度.C++代码: #include <iostream ...

  6. Codeforces Round #321 (Div. 2) Kefa and First Steps 模拟

    原题连接:http://codeforces.com/contest/580/problem/A 题意: 给你一个序列,问你最长不降子串是多长? 题解: 直接模拟就好了 代码: #include< ...

  7. Codeforces Round #321 (Div. 2) A, B, C, D, E

    580A. Kefa and First Steps 题目链接: A. Kefa and First Steps 题意描述: 给出一个序列,求最长不降连续子序列多长? 解题思路: 水题,签到 代码: ...

  8. Codeforces Round #321 (Div. 2)

    水 A - Kefa and First Steps /************************************************ * Author :Running_Time ...

  9. animation-timing-function: steps() 详解

    在应用 CSS3 渐变/动画时,有个控制时间的属性 <animation-timing-function> .它的取值中除了常用到的 贝萨尔曲线以外,还有个让人比较困惑的 steps()  ...

随机推荐

  1. I2C controller core之Bit controller(03)

    FPGA proven, AISC proven, I2C controller core from OpenCores http://opencores.org/project,i2c Bit-co ...

  2. JSP状态管理_1_Cookie

    http协议的无状态性:当浏览器发送请求飞服务器时,服务器相应客户端请求:但当同一个浏览器再次发送请求给浏览器时,服务器并不知道它就是刚才那个客户端. 保存用户状态的两大机制:Session,Cook ...

  3. POJ_2063_完全背包

    Investment Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10090   Accepted: 3540 Descr ...

  4. Swift Method Dispatching — a summary of my talk at Swift Warsaw

    Swift Method Dispatching When announcing Swift, Apple described it as being much faster than Objecti ...

  5. EF test

    LibraryEntities db = new LibraryEntities(); private void btnSelect_Click(object sender, EventArgs e) ...

  6. CryptoJS简单使用(request.js) 拦截器的使用

    首先准备一份明文和秘钥: var plaintText = 'aaaaaaaaaaaaaaaa'; // 明文var keyStr = 'bbbbbbbbbbbbbbbb'; // 一般key为一个字 ...

  7. hibernate与spring整合

    Spring与Hibernate整合关键点: 1) Hibernate的SessionFactory对象交给Spring创建: 2) hibernate事务交给spring的声明式事务管理. 1. D ...

  8. 【udacity】机器学习-神经网络

    Evernote Export 1.神经网络 神经元 细胞的主体称为细胞体,然后有轴突.突触 他们构建的方式是可以调整的 我们会有一些输入的放电信号视为放电频率或输入的强度 X1​w1​X2​w2​X ...

  9. 为什么要学习vue?

    Vue是什么?来看看官方的介绍. Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库只 ...

  10. cat和cp的神奇用法:制作U盘安装盘

    使用U盘安装debian,U盘的制作方法: 方法一: https://www.debian.org/doc/manuals/debian-handbook/installation.zh-cn.htm ...