Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - A
题目链接: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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - D
题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - C
题目链接:http://codeforces.com/contest/831/problem/C 题意:给定k个评委,n个中间结果. 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果, ...
随机推荐
- 拆系数$FFT$($4$遍$DFT$)
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> ...
- es之java插入优化(批量插入)
插入文档操作的一种优化,因为每次插入单条文档,都会向es中发送请求.然后es执行在返回结果: 如果有大批量的文档数据需要插入,这个时候单挑插入操作显然是不合理的: 之前学习的命令行批量执行方式: PO ...
- Java数据结构与算法(1):线性表
线性表是一种简单的数据类型,它是具有相同类型的n个数据元素组成的有限序列.形如如A0,A1,...,An-1.大小为0的表为空表,称Ai后继Ai-1,并称Ai-1前驱Ai. printList打印出表 ...
- java中 使用输入+输出流对对象序列化
对象: 注意记得实现 Serializable package com.nf147.sim.entity; import java.io.Serializable; public class News ...
- CentOS7 日常操作 2
常用命令 文件与目录操作 命令 解析 cd /home 进入 ‘/home’ 目录 cd .. 返回上一级目录 cd ../.. 返回上两级目录 cd - 返回上次所在目录 cp file1 file ...
- MongoDB 基本命令备忘
使用admin数据库: use admin 显示数据库: show dbs 创建用户,并制定该用户的角色: db.createUser({user: "root",pwd:&quo ...
- 非web工程,打jar放shell执行
作为6年经验的程序员,一直在搞web服务应用开发,今天领导被吐槽了,只会web方面的东东,最基本的打包啥啥都不会.. 一般开发工程都是web项目,突然要求开发非web,不用tomcat装(浪费端口号) ...
- nginx proxy_pass 和 proxy_redirect
proxy_pass:充当代理服务器,转发请求proxy_redirect:修改301或者302转发过程中的Location.默认值为proxy_redirect default. 例:locatio ...
- JSONPath解析json
JSONPath - 用于JSON的XPath 用来解析多层嵌套的json数据;JsonPath 是一种信息抽取类库,是从JSON文档中抽取指定信息的工具. 考虑到接下来计划开发一个自动化测试平台,在 ...
- hbase的API
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.*; import org.apache.had ...