codeforces 580A Kefa and First Steps
来源:互联网 发布:windows.iso怎样安装 编辑:程序博客网 时间:2024/06/05 15:21
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 sequenceai. 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!
The first line contains integer n (1 ≤ n ≤ 105).
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).
Print a single integer — the length of the maximum non-decreasing subsegment of sequencea.
62 2 1 3 4 1
3
32 2 9
3
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.
AC:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
long long a[100010];
scanf("%d",&n);
int maxx=1,sum=1;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=1;i<n;i++)
{
if(a[i]>=a[i-1])
{
sum++;
maxx=max(maxx,sum);
}
else
{
maxx=max(maxx,sum);
sum=1;
}
}
printf("%d",maxx);
}
- 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
- strlen, strcat, strcmp, strcpy函数
- HBase (2)---数据存储结构
- Intellij IDEA2017 scala环境搭建
- React 16 新特性
- VS Code编辑器快捷键使用
- codeforces 580A Kefa and First Steps
- swig入门
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- Application
- 数据结构实验之查找一:二叉排序树
- c中打开文件
- hibernate3 @Id 与 @Column位置的问题
- 入库时效列表
- 常见zz错误