CodeForces 580A Kefa and First Steps

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415794.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

微信支付 商户Key 支付Key API密钥 的获取

读了微信支付的开发文档&#xff0c;感觉是不同阶段&#xff0c;不同的同学写的&#xff0c;有些专业名词比较混乱&#xff0c;甚至还会有错别字&#xff0c;以及接口更新了&#xff0c;而文档不更新的情况。 使用微信支付&#xff0c;必须要用到 api密钥进行签名 其中 &…

oracle 10g 报错:ORA-00257: archiver error. Connect internal only, until freed

今天在公司&#xff0c;突然同事告诉我数据库无法登录了&#xff0c;想想这段时间没有动过库&#xff0c;为什么无法登录呢&#xff1f;一边想是什么问题&#xff0c;一边连接测试登录。 首先报错&#xff1a;ORA-00257: archiver error. Connect internal only, until freed.…

android 获取键盘回车键事件,设置软键盘回车键显示内容,点击空白处隐藏软键盘

首先设置EditText的回车属性 drawable文件 drawable/editcolor <?xml version"1.0" encoding"utf-8"?> <shape xmlns:android"http://schemas.android.com/apk/res/android" android:shape"rectangle"><size andro…

微信支付 签名算法 sign node实现

开发微信支付过程中&#xff0c;第一道门槛就是微信支付接口签名&#xff0c;只要按照官方文档写&#xff0c;就不会有什么错。 1、官方签名文档地址 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter4_3 2、我的实现 // 获取微信签名 getSign: (para…

触发器定义

create trigger atf on dbo.a after insertasbegin truncate table aend转载于:https://www.cnblogs.com/huanglong1987/p/7587570.html

android RecyclerView EditText 取消自动聚焦

在manifest中的activity中配置 android:windowSoftInputMode"adjustPan"

使用WINPE在硬盘安装WIN7系统

使用WINPE在硬盘安装WIN7系统 看到此标题&#xff0c;可能好多朋友会说&#xff0c;安装个WIN7操作系统&#xff0c;使用安装盘直接安装就是了&#xff0c;有必要做个文章介绍吗&#xff1f;的确&#xff0c;安装操作系统&#xff0c;最方便最简单的方法&#xff0c;就是使用系…

微信开发基础 获取用户OpenID 列表

1、官方文档 https://mp.weixin.qq.com/wiki?tresource/res_main&idmp1421140840 2、我使用的请求库是superagent&#xff0c;核心代码如下 /*** 获取公众号用户OpenID列表* param {*} request * param {*} h */ userOpenIdList: async function (request, h) {const ac…

%=%、%%、%@%、%#%的区别

1、<% %> 里面放变量名&#xff0c;获取后台的变量值,直接输入变量到页面上&#xff0c;里面放的变量名,未经过encode eg&#xff1a; 后台&#xff1a; seession["ab"]ab; 前台&#xff1a;<% session["ab"] %> 取值 <%&#xff1a;%&g…

SharedPreferences保存对象以及集合,腾讯MMKV使用,保存搜索历史

腾讯MMKV使用 implementation com.tencent:mmkv-static:1.2.9 MMKV.initialize(this);//会返回MMVK存储的目录&#xff08;String&#xff09; 创建MMKV&#xff0c;可以通过 defaultMMKV() 来创建&#xff0c;这个是全局默认的&#xff1b;也可以通过 mmkvWithID() 对应自己业…

QC与WIN7、IE8 兼容问题解决方案

QC与win7不兼容 1、 通过开始菜单搜索框&#xff0c;输入UAC&#xff0c;会出现“更改用户帐户控制设置”&#xff08;ChangeUser Account Control菜单 项。点击打开后&#xff0c;通过滚动条选择“从不通知”。 2、 打开cmd命令行&#xff0c;运行如下命令&#xff1a;bcd…

unity3d 鼠标延各个方向拖拽物体

using UnityEngine; using System.Collections;//选择轴向 public enum directionEnum{x_dir,y_dir,z_dir, } public class DragObject : MonoBehaviour {// Use this for initializationpublic directionEnum myDirection;public Transform target;//需要拖拽的目标public boo…

微信开发 根据openid 获取用户基本信息

1、官方文档 https://mp.weixin.qq.com/wiki?tresource/res_main&idmp1421140839 2、我的核心代码 /*** 根据openid获取用户详情* param {*} request * param {*} h */ userInfoByOpenId: async function (request, h) {const { openid } request.params;const access_…

Android应用程序显示未读消息计数

在build.gradle下添加依赖 compile me.leolin:ShortcutBadger:1.1.16aar 显示 ShortcutBadger.applyCount(context, num); 删除 ShortcutBadger.removeCount(context); 附SharedPreferences工具类 创建Application public class MyApplication extends Application {private s…

软件质量的理解 摘录

对软件质量进行评估是软件测试的一个重要目的。软件测试人员必须理解软件质量的定义和度量原理。 质量是指产品或服务满足显式或隐含需求能力的功能和特性的总和。 我们在测试中&#xff0c;除了分析客户的显式需求外&#xff0c;还要分析客户的隐含需求&#xff1a; 显式需…

node 微信红包 证书出错,请登录微信支付商户平台下载证书

按照官方文档写的代码&#xff0c;测试给自己发红包时&#xff0c;提示证书出错&#xff0c;请登录微信支付商户平台下载证书。 我是用的superagent库&#xff0c;错误前的核心代码是: const url https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack; const xml …