由于前几天才写博客,把前几天的题补上

D - Unimodal Array CodeForces - 831A

Array of integers is unimodal, if:

it is strictly increasing in the beginning;
after that it is constant;
after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.

For example, the following three arrays are unimodal: [5, 7, 11, 11, 2, 1], [4, 4, 2], [7], but the following three are not unimodal: [5, 5, 6, 6, 1], [1, 2, 1, 2], [4, 5, 5, 6].

Write a program that checks if an array is unimodal.


Input


The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array.

The second line contains n integers a1, a2, …, an (1 ≤ ai ≤ 1 000) — the elements of the array.


Output


Print “YES” if the given array is unimodal. Otherwise, print “NO”.

You can output each letter in any case (upper or lower).

Examples


Input


6
1 5 5 5 4 2


Output


YES


Input


5
10 20 30 20 10


Output


YES


Input


4
1 2 1 2


Output


NO


Input


7
3 3 3 3 3 3 3


Output


YES

Note
In the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively).

题意:由于这道题是英文题,可能大家也会和我一样首先产生恐惧心理,于是就会放弃,但是理解题意之后就会发现其实也就是一道水题:主要就是判断一个数组是不是增平减的结构。
AC代码如下:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{int a[1005],n,i;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&a[i]);}for(i=1;i<n;i++){if(a[i]<=a[i-1])break;}for(;i<n;i++){if(a[i]!=a[i-1])break;}for(;i<n;i++){if(a[i]>=a[i-1])break;}if(i==n)printf("YES\n");elseprintf("NO\n");return 0;
}

小白心得

寒假训练营第一天(学会CB):D - Unimodal Array相关推荐

  1. 2018年牛客多校算法寒假训练营练习比赛(第一场)C. 六子冲

    2018年牛客多校算法寒假训练营练习比赛(第一场)C. 六子冲 题目链接 做法:模拟即可 #include <bits/stdc++.h> #define P pair<int,in ...

  2. 【题集】牛客网·2018年全国多校算法寒假训练营练习比赛(第二场)

    原文链接:2018年全国多校算法寒假训练营练习比赛(第二场) A 吐泡泡 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Form ...

  3. 【题集·待解决】牛客网·2018年全国多校算法寒假训练营练习比赛(第二场)

    原文链接:2018年全国多校算法寒假训练营练习比赛(第二场) A 吐泡泡 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Form ...

  4. 玩转用户标签体系,打造精细化运营底层能力 | 芒种训练营第一课

    本文根据 2020 神策数据分析芒种训练营第一课<玩转用户标签体系,打造精细化运营底层能力>课程整理所得. 作者介绍 本次课程主要分为三部分内容: 用户标签画像的价值 如何构建可落地的用户 ...

  5. 阿里云数据中台训练营第一期圆满落幕

    近日,由阿里巴巴数据中台团队主办的阿里云数据中台训练营第一期顺利落下帷幕.阿里云数据中台训练营旨在将阿里巴巴数据中台的理念.方法论.技术.产品赋能给生态伙伴,以协同生态伙伴更快推动阿里云上的企业进行数 ...

  6. 阿里云AI训练营第一天

    AI训练营 第一天 课程日期:21年03月22日,周一 阿里云视觉智能开放平台 "让天下没有难用的 AI"的目标,与阿里云"让天下没有难做的生意"的理念一脉相承 ...

  7. python免费训练营教程_鹅厂大牛亲授Python零基础寒假训练营视频教程

    目录:/093 鹅厂大牛亲授python零基础寒假训练营 $ U  t  E; k6 g, M- t┣━━(补充章节)  第八章第2节-集合序列操作,遍历及推导式.mp4 . l2 A: f8 {2 ...

  8. 【2023 · CANN训练营第一季】——Ascend C算子开发入门——第一次课

    前言:昇腾AI处理器的算子开发增加了一种新的方式,称之为TIK2,正式名称是Ascend C算子开发.不同于采用Python的DSL和TIK方式,Ascend C使用C/C++作为前端语言的算子开发工 ...

  9. 2018年全国多校算法寒假训练营练习比赛(第一场)G 圆圈

    链接:https://www.nowcoder.com/acm/contest/67/G 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...

  10. 2018年全国多校算法寒假训练营练习比赛(第一场)F. 大吉大利,今晚吃鸡——跑毒篇(模拟)

    链接:https://www.nowcoder.com/acm/contest/67/F 来源:牛客网 题目描述 现在有一款很火的游戏playerunknown's battlegrounds,人称& ...

最新文章

  1. 匿名管道 阻塞_Linux系统编程—有名管道
  2. java 分页查询_java开发之分页查询
  3. 论文阅读:SSD: Single Shot MultiBox Detector
  4. Oracle入门(十四.6)之使用标量数据类型
  5. 543. 二叉树的直径 golang
  6. 关于cocos2dx 3.x版本移植 dragonbones 4.5版本的解决方案
  7. 固体火箭发动机零维内弹道方程组
  8. raid 物理盘缓存状态_查看RAID状态
  9. 大学python课本_Python大学实用教程(大学计算机规划教材)/数据工程师系列
  10. scrapy 简单教程
  11. idea的output窗口丢失问题
  12. 百度Apollo仿真仿真平台搭建-附1
  13. 21闭关修炼 习题分册
  14. 内存:VSS/RSS/PSS/USS区别和监控
  15. 华大单片机HC32L136定时器时间如何计算
  16. VHDL编写3-8译码器
  17. python 爬虫 微博 github_GitHub 热门:各大网站的 Python 爬虫登录汇总
  18. [中国大学Mooc]Web前端测试题
  19. mem系列函数(memcpy)
  20. Java- Set 转换成List

热门文章

  1. 离散数学:用python实现矩阵乘法与关系矩阵
  2. 班门弄斧之机械设计理论
  3. java图片蒙版,在javafx中创建图像叠加蒙版
  4. 如何分享带淘宝客的链接到新浪微博
  5. x86 x64 arm64 安装包的区别
  6. c语言中变量要加引号吗,CMake中引号用法总结
  7. 云计算最终比拼的是什么?
  8. 银行与第三方支付平台的竞合关系分析
  9. java青蛙跳井_数学运算归纳
  10. java文字水印模糊_使用Java给图片添加文字水印并消除锯齿