Time limit
2000 ms
Memory limit
262144 kB

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.

Example
Input

6
2 2 1 3 4 1Output3Input3
2 2 9Output3

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.

思路:
最长子序列的在线处理。

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>using namespace std;int main(){int N;cin>>N;int tor;int now;cin>>tor;int maxx = 0;int sum = 1;while(--N){scanf("%d",&now);if(now>=tor)sum++;else {if(sum>maxx)maxx = sum;sum = 1;}tor = now;}if(sum>maxx)maxx = sum;cout<<maxx<<endl;return 0;
}

转载于:https://www.cnblogs.com/vocaloid01/p/9514246.html

CodeForces 580A Kefa and First Steps相关推荐

  1. 线段树 + 字符串Hash - Codeforces 580E Kefa and Watch

    Kefa and Watch Problem's Link Mean: 给你一个长度为n的字符串s,有两种操作: 1 L R C : 把s[l,r]全部变为c; 2 L R d : 询问s[l,r]是 ...

  2. codeforces 580D Kefa and Dishes

    传送门:http://codeforces.com/problemset/problem/580/d 思路:状压DP,f[i][j]表示最后一个为i,已选取的菜的状态为j. #include<c ...

  3. codeforces 580C Kefa and Park(DFS)

    题目链接:http://codeforces.com/contest/580/problem/C #include<cstdio> #include<vector> #incl ...

  4. Codeforces Round #321 (Div. 2)

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

  5. Codeforces Round #321 (Div. 2) C. Kefa and Park dfs

    C. Kefa and Park Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/probl ...

  6. Codeforces Round #321 (Div. 2) B. Kefa and Company 二分

    B. Kefa and Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/pr ...

  7. Codeforces Round #321 (Div. 2) Kefa and Company 二分

    原题链接:http://codeforces.com/contest/580/problem/B 题意: 给你一个集合,集合中的每个元素有两个属性,$m_i,s_i$,让你求个子集合,使得集合中的最大 ...

  8. 【CodeForces - 580D】Kefa and Dishes (状压dp)

    题干: kefa进入了一家餐厅,这家餐厅中有n个菜(0<n≤18),kefa对第i个菜的满意度为ai(0≤ai≤10^9),并且对于这n个菜有k个规则,如果kefa在吃完第xi个菜之后吃了第yi ...

  9. CodeForces 1139D Steps to One(概率dp 容斥/莫比乌斯反演)

    题目链接https://codeforces.com/contest/1139/problem/D 题意:给定一个m,每次在1-m中随机取一个数放到容器中,当容器的gcd为1时停止,求期望步数,用分数 ...

最新文章

  1. SpringMVC通过注解方式读取properties文件中的值
  2. 倍数应用题后面需要带单位吗_数学应用题解答思路解析(附例题)
  3. HDU6218 2017ACM/ICPC亚洲区沈阳站 Bridge(Set,线段树)
  4. 莫桑比克wcdma频段_开放医疗记录社区支持莫桑比克的新系统
  5. LeafGAN:一种有效的实用植物病害诊断数据扩充方法
  6. The Introduction Of Filter
  7. IKM 线上测试JavaScript
  8. Android跑马灯进度条,跑马灯进度条在Powershell中冻结
  9. matlab 矩阵元素平方和矩阵的平方
  10. 品牌营销策略:适合初创公司的5种营销方式
  11. 基于thinkphp校园二手交易网站——毕业设计
  12. 信用卡和借记卡、储蓄卡
  13. unity 鼠标放置 ui_ui层次结构以及不常见但至关重要的任务放置在哪里
  14. 2019年年终个人总结
  15. validationGroup和Page_ClientValidate()配合使用解决前端click事件返回为false时验证失效问题
  16. CSO面对面丨如何通过“联合作战”,加强银行安全体系建设
  17. 连续Hopfield神经网络的优化旅行商问题
  18. it工程师和码农的区别_工程师和码农的最大区别在哪
  19. 装载“90万亿元”后 中国经济巨轮怎么走?
  20. 华为新系统鸿蒙寓意,华为鸿蒙新名字正式宣布?寓意深远让人眼前一亮,这一次真的稳了...

热门文章

  1. c/c++面试试题(四)
  2. [react-router] React-Router的<Link>标签和<a>标签有什么区别
  3. [html] DOM节点的根节点是不是body?
  4. 前端学习(2850):简单秒杀系统学习之绝对定位
  5. 前端学习(2715):重读vue电商网站35之在sessionStorage保存左侧菜单栏的激活状态
  6. 前端学习(2653):对比vue2中的实现
  7. 前端学习(2611):vuex实现增加
  8. 工作100:v-model自定义是父亲组件得值
  9. “约见”面试官系列之常见面试题第四十篇之双向绑定以及实现原理(建议收藏)
  10. 前端学习(2055)vuejs的认识和特点介绍