CodeForces-831A-Unimodal Array (水题)
/*
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 (水题)的更多相关文章
- CodeForces - 831A Unimodal Array 模拟
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- CF451B Sort the Array 水题
Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- hdu 5532 Almost Sorted Array (水题)
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 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 ...
- 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 ...
随机推荐
- 自定义gradle plugin
最近开始接触gradle 正好有个需求apidoc
- MCU与FPGA通信
1.MCU启动FPGA相应功能模块 通过译码器选择相应的功能模块,调用实现功能. 2.MCU与FPGA串口通信 SPI协议简单.可靠.易实现,速度快,推荐使用SPI.SPI为四线机制,包含MOSI.M ...
- C# 面向对象三大特性:封装、继承、多态
面向对象有封装.继承.多态这三个特性,面向对象编程按照现实世界的特点来管理复杂的事物,把它们抽象为对象,具有自己的状态和行为,通过对消息的反应来完成任务.这种编程方法提供了非常强大的多样性,大大增加了 ...
- 曾经遇到的坑------href="#"和href="javascript:void(0);"、href="javascript:;"
这个是为了 在点击此链接后回到页首,如果你写href="#"那么点击后会回到页首,这样影响操作. <a href="javascript:void 0" ...
- 【TopCoder】SRM151 DIV2 练习总结
第一次做完整的SRM题,刷完感觉萌萌哒,不过自己对java中很多细节不熟练,还要边做题边google. 250分的题:判断字符串序列是否是前缀码,如果不是,返回第一个违反前缀码规则的字符串. 简单的暴 ...
- Eclipse与Tomcat的集成(无插件)
1.下载Eclipse(https://www.eclipse.org/downloads/)和Tomcat(http://tomcat.apache.org/),具体的安装略: 2.打开Eclips ...
- Swagger自动生成接口文档
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- keystone v2/v3
Changing from APIv2.0 to APIv3 in Keystone - Openstack Juno on Ubuntu 1. 更换v3 的policy文件 mv /etc/keys ...
- cell 配置
Cells Cell configuration options Configure the API (top-level) cell Configure the child cells Config ...
- Oracle创建表空间和增加表空间
1.创建表空间 create tablespace fgq datafile 'E:\app\Administrator\oradata\fms\fgq01.dbf' size 1000M autoe ...