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 ...
随机推荐
- python中颜色设置
实现过程: 终端的字符颜色使用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关. 转义序列是以ESC开头,即用\033来表示(ESC是ASCII码用十进制表示是27,用八进制表示就是033 ...
- pyhton3 re模块
本文转自 AstralWind 的博客:Python正则表达式指南 特来收藏 1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一部分.正则表达式是用于处理字符串的强大工具,拥有 ...
- bfc (收集的)
一些基本概念 viewport: 展现网页的媒体,比如窗口或者某个区域,它的大小是有限制的,为了不被平台术语所束缚,我们给他起名viewport,中文意思就是视口. canvas: 而我们在渲染网页的 ...
- UI控件之UITabBarController
UITabBarController:标签栏控制器,继承自UIViewController,用标签栏的形式管理视图控制器,各标签栏对应的视图控制器之间相互独立,互不影响,单击标签栏,显示标签栏对应的视 ...
- first application
<!DOCTYPE html> <html> <head> <title>Create a Map</title> <meta htt ...
- 【HackerRank】Game Of Rotation
题目连接:Game Of Rotation Mark is an undergraduate student and he is interested in rotation. A conveyor ...
- uart测试代码
#include <stdio.h> /*标准输入输出定义*/ #include <stdlib.h> /*标准函数库定义*/ #include <unistd.h> ...
- 线性代数:Ax=b的解
n列的矩阵A,当且仅当向量b是列空间C(A)的一个向量时,Ax=b有解. C(A)的零空间是N(A),N(A)正交补是A的行空间C(T(A)), 依据上一章的结论,任何Rn向量可以表示为r+n,其中n ...
- Cocos2d-x项目移植到WP8系列之八:CCLabelTTF显示中文不换行
原文链接: http://www.cnblogs.com/zouzf/p/3985330.html 在wp8平台上,CCLabeTTF显示中文不会自动换行,看了下源码,原来底层的实现是根据text的空 ...
- OC_内存管理
引言: 1.OC中的对象都是分配在堆中的 声明对象的格式: Person *person = [Person new ...