题目链接

 /*
Name:
Copyright:
Author:
Date: 2018/5/6 19:34:23
Description:
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int arr[];
int main()
{
int n;
while (cin>>n) {
for (int i=; i<n; i++) {
cin>>arr[i];
}
if (n == ) {//
cout<<"YES"<<endl;
continue;
}
int flag = ;
for (int i=; i<n; i++) {
if (arr[i] != arr[i-]) flag = ;
}
if (flag == ) {//全相等
cout<<"YES"<<endl;
continue;
} bool destory = false;
if (arr[] == arr[]) {
int tmp = arr[];
int i = ;
while (arr[i] == arr[i-]) i++;
//不相等
for (; i<n; i++) {
if (arr[i] >= arr[i-]) {
destory = true;
break;
} else {
}
}
//判断完毕
if (destory) {
cout<<"NO"<<endl;
} else{
cout<<"YES"<<endl;
}
} else {
int i=;
//递增
while (arr[i] > arr[i-] && i<n) i++;
//相等
while (arr[i] == arr[i-] && i<n) i++;
//递减
while (arr[i] < arr[i-] && i<n) i++;
if (i == n) {
cout<<"YES"<<endl;
} else {
cout<<"NO"<<endl;
}
}
}
return ;
}

CodeForces-831A-Unimodal Array (水题)的更多相关文章

  1. CodeForces - 831A Unimodal Array 模拟

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

  2. CF451B Sort the Array 水题

    Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...

  3. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  4. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  5. hdu 5532 Almost Sorted Array (水题)

    Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  6. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  7. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  10. Educational Codeforces Round 11 A. Co-prime Array 水题

    A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...

随机推荐

  1. C/C++ 数据类型的使用方法详解

    cppreference.com -> C/C++ 数据类型 C/C++ 数据类型 C语言包含5个基本数据类型: void, integer, float, double, 和 char. 类型 ...

  2. php备份mysql数据库

    <?php /*程序功能:mysql数据库备份功能*/ ini_set('max_execution_time','0'); ini_set('memory_limit','1024M');// ...

  3. 【LeetCode】【动态规划】表格移动问题

    前言 这里总结了两道表格移动的问题,分别是:Unique Paths 和 题一:Unique Paths 描述 A robot is located at the top-left corner of ...

  4. Linux sh远程连接失败 sshd.service启动失败

    今天不小心在本机的虚拟机执行了 chmod -R 777 /var 导致/var目录下所有权限全部是777 其中 /var/empty/sshd目录权限必须是744,却被改成了777,致使sh远程连接 ...

  5. valn 配置

    内核修改: /device drivers/Network device support/MAC-VLAN support 1.创建目录和文件#cd /usr#mkdir vlan#cd vlan#c ...

  6. 初识python---简介,简单的for,while&if

    一编程语言:编程语言是程序员与计算机沟通的介质: 编程语言的分类:  1机器语言:是用二进制代码表示的计算机能直接识别和执行的一种机器指令的集合.           优点:灵活,直接执行和速度快   ...

  7. codeforces上某题

    一道codeforces上的题目. 题目大意: 定义有k个不同的字符的字符串为好字符串.现在给出一个字符串,求解对该字符串的每个前缀Si至少是多少个好字符串的连接,若不能由好字符串连接而成则输出-1. ...

  8. 数独C语言算法

    备好:http://blog.chinaunix.net/uid-26456800-id-3380612.html

  9. USB引脚及定义

    USB 2.0 USB接口定义: USB引脚定义: 针脚 名称 说明 接线颜色 1 VCC +5V电压 红色 2 D- 数据线负极 白色 3 D+ 数据线正极 绿色 4 GND 接地 黑色   Min ...

  10. INSPIRED启示录 读书笔记 - 第26章 合理运用敏捷方法

    十大秘诀 1.产品经理即是产品负责人,他代表了客户的需求,因而需要与产品开发团队保持密切的联系,协助督促开发进程,及时解决出现的问题 2.使用敏捷方法绝不等于省略产品规划.规划周期应该适度缩短,反复迭 ...