A - Kefa and First Steps
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的更多相关文章
- 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 ...
- Codeforces 580A - Kefa and First Steps
580A - Kefa and First Steps 思路:dp dp[i]表示包括前i个元素中a[i]在内的最大增序列. 代码: #include<bits/stdc++.h> usi ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #321 (Div. 2) Kefa and First Steps 模拟
原题连接:http://codeforces.com/contest/580/problem/A 题意: 给你一个序列,问你最长不降子串是多长? 题解: 直接模拟就好了 代码: #include< ...
- Codeforces Round #321 (Div. 2) A, B, C, D, E
580A. Kefa and First Steps 题目链接: A. Kefa and First Steps 题意描述: 给出一个序列,求最长不降连续子序列多长? 解题思路: 水题,签到 代码: ...
- Codeforces Round #321 (Div. 2)
水 A - Kefa and First Steps /************************************************ * Author :Running_Time ...
- animation-timing-function: steps() 详解
在应用 CSS3 渐变/动画时,有个控制时间的属性 <animation-timing-function> .它的取值中除了常用到的 贝萨尔曲线以外,还有个让人比较困惑的 steps() ...
随机推荐
- Christopher G. Atkeson 简介
有一个事实:双足机器人的稳定性问题单靠算法是搞不定的!!! 在2015 DARPA 机器人挑战赛中,许多参赛团队的机器人使用了Atlas,他们通过安装他们自己的软件并修改来让机器人保持平衡.来自WPI ...
- SLAM: Inverse Depth Parametrization for Monocular SALM
首语: 此文实现客观的评测了使线性化的反转深度的效果.整篇只在表明反转可以线性化,解决距离增加带来的增长问题,有多少优势--%! 我的天呢!我竟然完整得翻译了一遍. 使用标记点地图构建SLAM的方法, ...
- 揭开jQuery的面纱
简单地说,jQuery是一个优秀的JavaScript类库,也就是使用JavaScript面向对象的性质编写的一个JavaScript类的集合.jQuery究竟能为我们提供哪些功能呢?简单地说可以从七 ...
- 点击button 触发另一个button 事件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs&quo ...
- 【转】虚拟化(三):vsphere套件的安装注意及使用
vsphere套件里面主要的组件有esxi.vcenter server .vsphere client和vsphere web client. vcenter做为vsphere套件的核心管理成员之一 ...
- struts与spring整合
Spring与Struts框架整合 Spring,负责对象对象创建 Struts, 用Action处理请求 Spring与Struts框架整合, 关键点:让struts框架action对象的创建,交给 ...
- Day5 练习
1. 2. 要加强对代码效率的思考 3. 4. 知识点:1)多变量的同时赋值 2)元素的不可修改性:(1,2)=(3,4)与(a,b)= (b,a) 联想指针.地址去理解 :可用id()或t ...
- 非传统题初探——AtCoder Practice Contest #B - インタラクティブ練習 (Interactive Sorting)
原题: Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement This is an interac ...
- 八进制、十六进制与十进制的转换,bytes的十六进制
二进制.八进制.十六进制与十进制的不同顾名思义在于进位不同: 十进制遇十进一,9+1=10,19+1=20,199+1=200.相同数字前一位是后一位的十倍,例如11,前一个代表10,后一个是1. 一 ...
- MYSQL(一) 简单语法
MYSQL(一) 简单语法 1.默认约束:mysql里面DEFAULT关键字后面是不用加括号的 --1.1 创建数据库 mysql> create database holly; Query O ...