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. Ubuntu安装中文语言包

    使用Ubuntu 默认的界面感觉不习惯,于是安装KDE界面. 1.安装kde 使用命令行: sudo apt-get install kubuntu-desktop 安装后发现不能使用中文, 在 se ...

  2. .NET Core & EntityFrameworkCore

    前言 .NET Core 相比于 .NET Fromework 有跨平台.轻量化且开源的优势. 在使用 EntityFrameworkCore 的时候也遇到了很多问题,至于网络上的教程嘛...大部分都 ...

  3. 【技术累积】【点】【sql】【17】了解索引

    先上结论 数据库数据以平衡树进行聚合索引--主键的作用: 数据每行都存在叶子节点: 单独字段的索引,单独存在,且将该字段值取出: 单独字段的索引,查到对应的主键id,再通过聚合索引查到数据: 多字段索 ...

  4. C# tostring("0000000")

    public string ConverNo(string str) { string result = ""; ]; ; i < chars.Length; i++) ch ...

  5. logger日志

    Level 描述 ALL 各级包括自定义级别 DEBUG 指定细粒度信息事件是最有用的应用程序调试 ERROR 错误事件可能仍然允许应用程序继续运行 FATAL 指定非常严重的错误事件,这可能导致应用 ...

  6. String类练习统计一个字符串中大小写字母及数字字符个数

    public class StringPractice { public static void main(String[] args) { //创建一个文本扫描器 Scanner sc = new ...

  7. 团体程序设计天梯赛-练习集-L1-038. 新世界

    L1-038. 新世界 这道超级简单的题目没有任何输入. 你只需要在第一行中输出程序员钦定名言“Hello World”,并且在第二行中输出更新版的“Hello New World”就可以了. #in ...

  8. loadrunner报错总结

    1.报错   没有缓存空间可用   TCP超时释放时间?是解决刚才那个报错的? 解决方法如下  修改TcpTimedWaitDelay值为1和MaxUserPort值为65534.最后,重启!  完美 ...

  9. 【剑指Offer】49、把字符串转换成整数

      题目描述:   将一个字符串转换成一个整数(实现Integer.valueOf(string)的功能,但是string不符合数字要求时返回0),要求不能使用字符串转换整数的库函数. 数值为0或者字 ...

  10. 接口测试与Postman

    阅读目录 1.接口测试简介 1.1 什么是接口测试  1.2 接口测试的必要性 1.3 接口测试流程 1.4 接口文档 1.5 接口测试用例设计 1.6 接口测试用例模板 2.Postman 2.1 ...