Description

Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed height and due to the newest irrigation system we can create artificial rain above each section.

Creating artificial rain is an expensive operation. That's why we limit ourselves to creating the artificial rain only above one section. At that, the water from each watered section will flow into its neighbouring sections if their height does not exceed the height of the section. That is, for example, the garden can be represented by a 1 × 5 rectangle, where the section heights are equal to 4, 2, 3, 3, 2. Then if we create an artificial rain over any of the sections with the height of 3, the water will flow over all the sections, except the ones with the height of 4. See the illustration of this example at the picture:

As Petya is keen on programming, he decided to find such a section that if we create artificial rain above it, the number of watered sections will be maximal. Help him.

Input

The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.

Output

Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.

Sample Input

Input
1
2

Output
1

Input
5
1 2 1 2 1

Output
3

Input
8
1 2 1 1 1 3 3 4

Output
6
题意:
输入一组数,在这组数当中,存在若干山形数组,其特点是中间(不一定是中点)存在 一个最大数,从这个数向左或者向右依次
减小,求其中最长数组的长度。
代码如下
<pre name="code" class="cpp">#include<stdio.h>
int a[1010];
int main()
{int n;while(scanf("%d",&n)!=EOF){for(int i=0;i<n;i++){scanf("%d",&a[i]);}int maxnum=-1;for(int i=0;i<n;i++){int m=i;int l=1;for(int j=m-1;j>=0;j--){if(a[j]>a[m])  break;m--;l++;}m=i; for(int j=m+1;j<n;j++){if(a[j]>a[m])break;l++;m++;}if(l>maxnum)maxnum=l;}printf("%d\n",maxnum);}
}

Petya and Countryside相关推荐

  1. 【翻译】旧技术成就新勒索软件,Petya添加蠕虫特性

    原文链接:https://blogs.technet.microsoft.com/mmpc/2017/06/27/new-ransomware-old-techniques-petya-adds-wo ...

  2. Petya and Exam

    Description It's hard times now. Today Petya needs to score 100 points on Informatics exam. The task ...

  3. 【英语学习】【Level 07】U02 Live Work L6 A countryside house

    文章目录 Word Preparation countryside: 乡村,农村 farmhouse: 农舍,农庄 one-storey: 一层的 wood panel: 木板 modern furn ...

  4. codeforces 111A/112C Petya and Inequiations

    题目:Petya and Inequiations 传送门: http://codeforces.com/problemset/problem/111/A http://codeforces.com/ ...

  5. Petya and Exam 模拟

    It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...

  6. Petya勒索病毒(2016.4月样本)分析笔记

    前言 之所以不叫分析报告,是因为接下来要看到的分析,可能包含了不正确的,或者有疑点,和未完全分析的,里面有我个人的主观臆断,或者一些我目前未察觉的错误,还有一些非常基础,非常啰嗦的内容,这都是为了复习 ...

  7. Petya and Strings

    文章目录 一.Petya and Strings 总结 一.Petya and Strings 本题链接: 题目: A. Petya and Strings time limit per test2 ...

  8. 112A.Petya and Strings

    112A.Petya and Strings 题目 翻译 题目 输入 输出 分析 代码 题目 翻译 题目 小Petya喜欢礼物.他妈妈为了他的生日买来了2个相同长度的字符串.字符串由大小写拉丁字母组成 ...

  9. petya病毒分析_首先是WannaCry,现在是Petya –防范大规模勒索软件攻击

    petya病毒分析 Just a month after the sweeping WannaCry attacks, we now see a new ransomware threat, a Pe ...

最新文章

  1. matlab 多个表数据相加,Excel合并计算完成多表格数据汇总求和
  2. 信通院2018人工智能发展白皮书技术篇重磅发布
  3. sql2000安装时报错的问题--实例挂起和267目录名无效
  4. [云炬创业基础笔记] 第三章测试3
  5. Java并发编程的艺术,解读并发编程的优缺点
  6. MineCraft和堆外内存
  7. Linux 目录详细说明
  8. 【AtCoder - 4244 】AtCoder Express 2 (区间dp 或 暴力枚举,思维)
  9. 《剑指offer》面试题31——连续子数组的最大和
  10. 三角测量计算三维坐标的代码_BIM+GIS——无人机倾斜摄影三维建模方法详解
  11. 结对作业 ——UI组第八组 冯富禹 齐天浩
  12. 原生js模拟微信聊天记录
  13. php 对账单系统,微信支付PHP开发教程八下载对账单
  14. API接口安全性设计
  15. 加油站踩踏式逃亡?电网成大赢家?时代抛弃你的时候,真的一声不吭
  16. 工具及方法 - 查询IP信息
  17. php绕过授权下载,Discuz附件下载权限绕过方法
  18. Dubbo——Merger的实现
  19. Gson踩坑笔记:为什么对象的构造方法没有被执行?
  20. Apsara Clouder云计算专项技能认证:云服务器ECS入门

热门文章

  1. 不看后悔!阿里内部技术参考图册算法篇!(附网盘链接)
  2. 请注意!新办理的电话卡,有以下情况会导致“二次实名”!
  3. playbook中的block rescue always
  4. 谈谈创业公司给服务器放在云端的优势和缺陷
  5. 索引及其背后的数据结构(顺带介绍了一下子查询和合并查询)
  6. Oulipo HDU - 1686 (使用扩展kmp进行讨伐!)
  7. 基于Mathcad的LLC公式推导与化简(一)
  8. 我在哪?要到哪里去?怎么去?
  9. 快手财报,广告、直播、电商齐头并进
  10. 程序中unsigned char 类型的意义