题目链接: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. scanf()函数原理

    一.三点说明 1.用户输入的字符,会以ASCII码形式存储在键盘缓冲区:2.每调用一次scanf函数,就从键盘缓冲区读走一个字符,相当于清除缓冲区:3.若用户一次输入n个字符,则前n次调用scanf函 ...

  2. 使用visual studio配置和运行《opengl圣经》的第一个案例

    对vc++新手来说,想把opengl圣经里的教学案例运行起来还真不是一件容易的事情,而且并没有完整的操作流程教学,这里就总结一下吧: 先安装cmake,用于生成vs的工程文件,安装过程中选中“将目录添 ...

  3. EasyUI combotree 设置节点折叠和叶子节点循环展开的BUG

    树实体 public class Combotree { public string id { get; set; } public string text { get; set; } public ...

  4. Jeecg心得篇--这个世界不缺程序员,而是缺少匠人和架构师

    真正的快乐,是用自己喜欢的方式过完这一生.来人间一趟,不能只为了活着. 这个世界不缺程序员,而是缺少匠人精神的架构师与产品经理. 因为他们通过自己的行为与理念默默地改变着世界,一个更好的世界. 这是我 ...

  5. WPF Good UI 2

    自定义一个漂亮的window窗口UI <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation& ...

  6. c# 用DotNetZip来解压/压缩文件

    //https://archive.codeplex.com/?p=dotnetzip //最新在Nuget 下载DotNetZip using Ionic.Zip; private void but ...

  7. Win7下64位机安装SQL2000

    win7下64位机安装SQLSERVER20001.右击计算机属性,查看操作系统 2.打开安装文件夹,按图点击 3.开始安装 4. 下一步选择 安装SQL Server2000 组件 5. 下一步 选 ...

  8. JavaScript 基础类型,数据类型

    1.基础类型:undefined,null,Boolean,Number,String,Symbol Undefined类型:一个没有被赋值的变量会有个默认值undefined; Null类型:nul ...

  9. Shell脚本中的特殊字符(美元符、反斜杠、引号等)作用介绍

    Shell中的特殊字符有 1.$ 美元符 2.\ 反斜杠 3.` 反引号 4." 双引号 5.< ,>;,*,?,[,] 下面我一一举列说明 一.$符号 1.echo $? 显示 ...

  10. Matlab入门基础

    matlab入门篇,一些基础用法记一下~ M语言是解释型语言 ​ who:查看当前变量 ​ whoes:查看当前变量及其维数.所占字节数等. ​ clear: 清除所有变量 ​ clear + 变量名 ...