Codeforces Round #321 (Div. 2) A. Kefa and First Steps
2015-09-23 19:48
363 查看
A. Kefa and First Steps
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 makesai 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.
Sample test(s)
input
output
input
output
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.
求一个序列的连续不降子序列。一个简单dp
dp[i]表示以第i个数为结尾的最长连续不降子序列。
转移方程dp[i]=a[i]>=a[i-1]?dp[i-1]+1:1;
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 makesai 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.
Sample test(s)
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.
求一个序列的连续不降子序列。一个简单dp
dp[i]表示以第i个数为结尾的最长连续不降子序列。
转移方程dp[i]=a[i]>=a[i-1]?dp[i-1]+1:1;
相关文章推荐
- ViewPager用法的个人整理
- POJ C++程序设计 编程题#7:字符串排序
- HDU - 3264
- 转化JSON格式
- Python 学习 (二) Python中的循环
- MongoDB分组group
- 不用临时变量交换两个数的值
- sicily 1035. DNA matching
- 杭电acm--2034
- iOS7模拟器安装
- 配置文件的继承与覆盖: Machine.config / Web.config /子目录 Web.config
- Android Studio cannot launch avd in emulator解决方案
- sicily 1027. MJ, Nowhere to Hide
- 模拟Android路径浏览器
- tomcat启动报错No UserDatabase component found under key UserDatabase
- 第二次作业(个人项目实践)
- xubuntu编译OpencV2.4.2出现make交叉编译出现错误。
- Google apac 在线笔试round2
- C#中数组、ArrayList和List三者的区别
- C++函数返回引用