CodeForces-831A-Unimodal Array (水题)
题目链接
1 /* 2 Name: 3 Copyright: 4 Author: 5 Date: 2018/5/6 19:34:23 6 Description: 7 */ 8 #include <iostream> 9 #include <cstdio> 10 #include <cstring> 11 using namespace std; 12 int arr[1005]; 13 int main() 14 { 15 int n; 16 while (cin>>n) { 17 for (int i=0; i<n; i++) { 18 cin>>arr[i]; 19 } 20 if (n == 1) {//1 21 cout<<"YES"<<endl; 22 continue; 23 } 24 int flag = 1; 25 for (int i=0; i<n; i++) { 26 if (arr[i] != arr[i-1]) flag = 0; 27 } 28 if (flag == 1) {//全相等 29 cout<<"YES"<<endl; 30 continue; 31 } 32 33 bool destory = false; 34 if (arr[0] == arr[1]) { 35 int tmp = arr[0]; 36 int i = 2; 37 while (arr[i] == arr[i-1]) i++; 38 //不相等 39 for (; i<n; i++) { 40 if (arr[i] >= arr[i-1]) { 41 destory = true; 42 break; 43 } else { 44 } 45 } 46 //判断完毕 47 if (destory) { 48 cout<<"NO"<<endl; 49 } else{ 50 cout<<"YES"<<endl; 51 } 52 } else { 53 int i=1; 54 //递增 55 while (arr[i] > arr[i-1] && i<n) i++; 56 //相等 57 while (arr[i] == arr[i-1] && i<n) i++; 58 //递减 59 while (arr[i] < arr[i-1] && i<n) i++; 60 if (i == n) { 61 cout<<"YES"<<endl; 62 } else { 63 cout<<"NO"<<endl; 64 } 65 } 66 } 67 return 0; 68 }
转载于:https://www.cnblogs.com/evidd/p/9003420.html
CodeForces-831A-Unimodal Array (水题)相关推荐
- codeforces 1060a(思维水题)
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...
- Codeforces Gym 100286I iSharp 水题
Problem I. iSharp Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...
- CodeForces - 1287B Hyperset(暴力水题)
题目链接:点击查看 题目大意:给出"集合"的定义: 集合中必须有三个元素 每个元素的每个特征值必须全部相同或者全部不同,不能存在两者相同但与第三者不同 现在给出n个元素以及m个特征 ...
- CodeForces 931C Laboratory Work 水题,构造
*这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 ...
- 【CodeForces - 1066A~E】水题,模拟(有技巧),思维,题意难懂的模拟,二进制问题(有技巧)
A. 题目大意: x坐标上1~L有L个点都是整数,每v个长度就有一个灯亮着,但是有 [ l , r ] 这段区间上有列火车挡住了,问你能看到多少亮灯. 解题报告: 大水题啊,找几个样例就会发现需要特殊 ...
- CodeForces - 13A Numbers【水题】
题目链接:https://codeforces.com/contest/13/problem/A 暴力 #include <iostream> using namespace std; i ...
- CodeForces - 1042C (emmmmmm水题)
You are given an array aa consisting of nn integers. You can perform the following operations with i ...
- Educational Codeforces Round 30 A[水题/数组排序]
A. Chores time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...
- Codeforces 864 A Fair Game 水题
题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
最新文章
- Microbiome:揩老鼠皮毛揩来高分文章——野生哺乳动物的皮肤和肠道微生物群对环境污染做出的反应
- 以 OSGi 包的形式开发和部署 Web 服务
- 每天一道LeetCode-----复制无向图
- 目标检测系列(八)——CenterNet:Objects as points
- 常见的技术类英文字母含义总结,Localhost、SDK、URL 等(持续更新中)
- php 里如何进行时间比较,PHP实现时间比较和时间差计算的方法示例
- bz2解压命令_tar 命令
- top、kill实现进程结束
- Spring 常见注解原理和自定义@interface注解
- ubuntu完全卸载mysql
- java实现modbus rtu协议与 modscan等工具(4)rtu转tcp
- 红帽子linux系统下载服务器OS:Windows、Linux与Unix三分天下
- Polynomial Commitments代码实现【1】——scipr-lab/poly-commit(含不同曲线性能对比)
- Android项目旋转屏幕数据丢失的原因及解决
- 由《爆裂鼓手》引发的产品思考
- 数据结构习题--线性表
- 基于融合的低照度图像增强
- agv系统介绍_AGV有什么用
- 传感网应用开发知识点总结
- Spotlight安装