A. Unimodal Array
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
int a[],n,x;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
int l=,r=n;
while(l<n && a[l]<a[l+]) l++;
while(r> && a[r]<a[r-]) r--;
for(int i=l+;i<=r;i++)
if(a[i]!=a[l]) return puts("NO"),;
puts("YES");
return ;
}

Code froces 831 A. Unimodal Array的更多相关文章

  1. Codeforces831A Unimodal Array

    A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  2. CodeForces - 831A Unimodal Array 模拟

    A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. 【Codeforces Round #424 (Div. 2) A】Unimodal Array

    [Link]:http://codeforces.com/contest/831/problem/A [Description] 让你判断一个数列是不是这样一个数列: 一开始是严格上升 然后开始全都是 ...

  4. E - Unimodal Array CodeForces - 831A

    Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...

  5. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)

    http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...

  6. C++ std::array

    std::array template < class T, size_t N > class array; Code Example #include <iostream> ...

  7. Array.prototype.slice.call(document.querySelectorAll('a'), 0)

    Array.prototype.slice.call(document.querySelectorAll('a'), 0)的作用就是将一个DOM NodeList 转换成一个数组. slice()方法 ...

  8. [转]Passing Managed Structures With Strings To Unmanaged Code Part 3

    1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (w ...

  9. [转]Passing Managed Structures With Strings To Unmanaged Code Part 2

    1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (w ...

随机推荐

  1. CIKM 2013 Paper Modeling interaction features for debate side clustering

    中文简单介绍:本文对怎样对网上论坛讨论中用户交互关系进行统计建模分析进行了研究. 论文出处:CIKM'13. 英文摘要: Online discussion forums are popular so ...

  2. ubuntu下安装RemixOS双系统(Android x86)

    这篇文章主要讲在怎样在ubuntu下安装RemixOS pc版(Android x86版本号),下面两种做法的思路都适合安装不论什么版本号的Android x86版本号到ubuntu系统上,仅仅须要改 ...

  3. WireGuard 隧道的安装和使用,测试地址 ca.6tu.me

    WireGuard 端到端平等的网络隧道,测试地址 ca.6tu.me --------------------------------------------- 服务器:远程 Ubuntu18 , ...

  4. linux关于用户密码家目录总结

    创建用户及其家目录useradd -d /home/tomcat -m tomcat接着修改密码passwd tomcat usermod -s /sbin/nologin + 用户名 禁止登录ssh ...

  5. 启动springboot

    新建一个springboot项目,idea的做法:一般直接next就行 填写项目使用到的技术,上面的Spring Boot版本建议选择最新的稳定版,主要勾选上Web就可以了,如下图: 新建之后< ...

  6. org.xml.sax.SAXParseException: Content is not allowed in prolog

    sax错误:org.xml.sax.SAXParseException: Content is not allowed in prolog解决  标签: org. xml. sax. saxparse ...

  7. react-native使用androidstudio时,安卓模拟器reload菜单界面显示快捷键ctrl+M;

    react-native使用androidstudio时,安卓模拟器reload菜单界面显示快捷键ctrl+M:

  8. NOIP愤怒的小鸟

    愤怒的小鸟 Description: 给你\(n<=18\)个小猪,发射的小鸟轨迹为抛物线,求最小用多少个小鸟可以将小猪全部干掉 看到n很小,我想到了搜索,于是我用\(dfs\)枚举出,每个抛物 ...

  9. javascript——对象

    分类 JavaScript对象分类: 内置对象:由ECMAScript规范定义的对象或类,例如:数组.函数.日期(Date()).正则表达式 宿主对象:是由js解释器所嵌入的宿主环境(比如Web浏览器 ...

  10. System.GC.Collect();//垃圾回收,回收没有正常关闭的http连接

    System.GC.Collect();//垃圾回收,回收没有正常关闭的http连接