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个结果, ...
随机推荐
- layer 弹出层不能居中
$("#btnAdd").button("loading"); parent.layer.open({ title: '添加菜单', type: 2, maxm ...
- BZOJ 3329: Xorequ(数位dp+递推)
传送门 解题思路 可以把原式移项得\(x\)^\(2x\)=\(3x\),而\(x+2x=3x\),说明\(x\)二进制下不能有两个连续的\(1\).那么第一问就是一个简单的数位\(dp\),第二问考 ...
- [CSP-S模拟测试]:木板(数学)
题目传送门(内部题68) 输入格式 输入有若干行,每行一个整数$N$,以$0$结束 输出格式 每行一个整数表示方案数,方案不同当且仅当$E$.$F$.$G$的坐标不同 样例 样例输入: 1020100 ...
- ASYNC_NETWORK_IO等待事件和调优
测试反应测试数据库整体出现hang的情况,检查对应的等待事件,发现大量的resource_semaphore等待事件, 查看内存占用情况: SELECT * FROM sys.dm_exe ...
- What does the dot after dollar sign mean in jQuery when declaring variables?
https://stackoverflow.com/questions/22156664/what-does-the-dot-after-dollar-sign-mean-in-jquery-when ...
- Linux驱动开发6——DDR内存分配
1.kmalloc和kfree #include <linux/slab.h> void *kmalloc(size_t size, int flags); flag: GFP_ATOMI ...
- H5 刮图-刮一刮
<!DOCTYPE html><html><head><style>*{margin:0;padding:0} </style></h ...
- android hidl
1.定义.hal接口文件,如: 在vendor/sprd/interface中新建目录hello,其中定义好hidl接口,如: package vendor.sprd.hardware.hello@1 ...
- Openstack_通用技术_RPC 远程异步调用
目录 目录 RPC 一个通过 HTTP Request 调用操作函数的 RPC 实现样例 环境 接收 HTTP Request RPC 调用具体的操作函数 测试 RPC RPC: 同一个项目内的不同服 ...
- html php插入百度地图定位
CSS样式 1 2 3 4 <style> .iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hi ...