题目链接:http://codeforces.com/contest/831/problem/A

题意:给定一个序列,问你这个序列是否是单峰的。 定义单峰的序列为: (序列值的变化趋势)开始是递增的,然后是平缓的,最后是递减的。

对于开始(递增)和结尾(递减)的那部分可以不出现

思路:按照题目判即可。

import java.io.*;
import java.util.*; public class Main {
public static final int MAXN=100+24;
public static int n;
public static int[] val=new int[MAXN];
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
n=cin.nextInt();
for(int i=1;i<=n;i++){
val[i]=cin.nextInt();
}
int up=n+1,down=0;
for(int i=1;i<n;i++){
if(val[i] >= val[i+1]){
up=i; break;
}
}
for(int i=n;i>1;i--){
if(val[i] >= val[i-1]){
down=i; break;
}
}
boolean flag=true;
for(int i=up;i<down;i++){
if(val[i]!=val[i+1]){
flag=false;
break;
}
}
out.println(flag?"YES\n":"NO\n");
out.flush(); out.close(); cin.close();
}
}

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - A的更多相关文章

  1. 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 ...

  2. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法

    Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...

  3. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C

    A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...

  4. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力

    题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...

  5. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  6. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 831E) - 线段树 - 树状数组

    Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...

  7. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B

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

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组

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

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

    题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...

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

    题目链接:http://codeforces.com/contest/831/problem/C 题意:给定k个评委,n个中间结果. 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果, ...

随机推荐

  1. Spring Cloud Commons教程(二)Spring RestTemplate作为负载平衡器客户端

    RestTemplate可以自动配置为使用功能区.要创建负载平衡RestTemplate创建RestTemplate @Bean并使用@LoadBalanced限定符. 警告 通过自动配置不再创建Re ...

  2. 5.React中组件通信问题

    1.父组件传递值给子组件 想必这种大家都是知道的吧!都想到了用我们react中的props,那么我在这简单的写了小demo,请看父组件 class Parent extends Component{ ...

  3. python开发环境准备

    python 以版本众多,包之间依赖复杂而著称,所以一个趁手的开发环境还是很有必要的. 我的建议是用Anaconda做环境隔离.包管理,PyCharm做项目开发,jupyter做笔记,ipython和 ...

  4. Linux内核调试方法总结之Jprobes

    Jprobes [用途] 类似于Kprobes和Return Probes,区别在于,Kprobes可以在任意指令处插入探针,Jprobes只在函数入口插入探针,而Return Probes则是在函数 ...

  5. page size

    https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_page_size https://dev.mysql.com/doc/refma ...

  6. JS new date在IOS出现的问题

    实例代码: input = input.replace(/\-/g, "/");//横杠的时间不能被识别,所以要替换程斜杠 let time = new Date(input); ...

  7. 阶段1 语言基础+高级_1-3-Java语言高级_04-集合_06 Set集合_7_可变参数

    打印出来是一个数组的地址 打印数组的长度 只要调用了add方法就会创建一各长度为0的数组 传一个10过去.就输出了数组的长度为1 传两个数字 注意事项: 特殊写法

  8. rpm安装软件时提示warning: *.rpm: Header V3 RSA/SHA256 Signature, keykey ID c105b9de

    在RedHat下有时候用rpm安装软件是会出现下面则中错误 1.安装时提示:warning: *.rpm: Header V3 RSA/SHA256 Signature, keykey ID c105 ...

  9. python2.7+appium第一个脚本(使用夜神模拟器)

    搭建好环境后,可以开始准备脚本的编写工作 目录 1.安装夜神模拟器 2.使用uiautomatorviewer定位 3.运行第一个脚本 1.安装夜神模拟器 第一步:官网下载夜神模拟器,完成安装 双击下 ...

  10. ensorflow学习笔记四:mnist实例--用简单的神经网络来训练和测试

    http://www.cnblogs.com/denny402/p/5852983.html ensorflow学习笔记四:mnist实例--用简单的神经网络来训练和测试   刚开始学习tf时,我们从 ...