CodeForces 580A Kefa and First Steps
来源:互联网 发布:即时通讯app源码下载 编辑:程序博客网 时间:2024/05/17 01:14
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
62 2 1 3 4 1Output3Input32 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;}
阅读全文
0 0
- CodeForces 580A Kefa and First Steps
- Codeforces 580A Kefa and First Steps
- Codeforces-580A-Kefa and First Steps
- CodeForces 580A Kefa and First Steps
- codeforces 580A Kefa and First Steps
- codeforces 580A Kefa and First Steps
- codeforces 580A(Kefa and First Steps) Java
- coderforce 580A Kefa and First Steps
- Codeforces Kefa and First Steps
- A. Kefa and First Steps
- Codeforces Round #321 (Div. 2) A. Kefa and First Steps
- Codeforces Round #321 (Div. 2) A. Kefa and First Steps
- Codeforces Round #321 A Kefa and First Steps
- Codeforces Round #321 (Div. 2) 580A Kefa and First Steps(模拟)
- 580A. Kefa and First Steps (Codeforces Round #321 (Div. 2))
- Codeforces Round #321 (Div. 2) 580A. Kefa and First Steps
- Code Forces 580 A. Kefa and First Steps(水~)
- Kefa and First Steps
- Java中创建对象的几种方式
- 轻量级框架SSH应用与开发——Hibernate之学习总结(进阶)
- Batch Normalization Accelerating Deep Network Training by Reducing Internal Covariate Shift 阅读笔记与实现
- Mac下配置环境变量
- String,StringBuffer,StringBuilder
- CodeForces 580A Kefa and First Steps
- 大话数据结构
- 2017WHCTF
- 技术大牛总结的Github与华为软件开发云完整对比
- 用e=1/1!+1/2!+1/3!+……公式求e的近似值,直到发现某一项的值小于10^(-5)为止;
- tf.nn.top_k() tf.nn.in_top_k()
- window系统如何恢复/查看swp文件
- mybatis3通过provider注解结合动态sql实现增删改查,不再依赖xml成为可能
- kubernetes简介