题干:

A sequence of  integers  is called a peak, if and only if there exists exactly one integer  such that , and  for all , and  for all .

Given an integer sequence, please tell us if it's a peak or not.

Input

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer  (), indicating the length of the sequence.

The second line contains  integers  (), indicating the integer sequence.

It's guaranteed that the sum of  in all test cases won't exceed .

Output

For each test case output one line. If the given integer sequence is a peak, output "Yes" (without quotes), otherwise output "No" (without quotes).

Sample Input

7
5
1 5 7 3 2
5
1 2 1 2 1
4
1 2 3 4
4
4 3 2 1
3
1 2 1
3
2 1 2
5
1 2 3 1 2

Sample Output

Yes
No
No
No
Yes
No
No

题目大意:

给你一组数,问你能否凑出一个是山峰的情况。即这组数先递增然后再递减。

解题报告:

注意判断不能一直递增或者一直递减就可以了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
int n;
ll a[MAX];
int main()
{int t;cin>>t;while(t--) {scanf("%d",&n);for(int i = 1; i<=n; i++) scanf("%lld",a+i);int tar,flag = 1;if(a[1] >= a[2] || a[n-1] <= a[n]) {printf("No\n");continue;}for(int i = 2; i<=n-1; i++) {if(a[i] < a[i+1]) continue;else {tar = i;break;}}for(int i = tar; i<=n-1; i++) {if(a[i] > a[i+1]) continue;else {flag = 0;break;}}if(flag) printf("Yes\n");else printf("No\n");}return 0 ;
}

【ZOJ - 4024】Peak(模拟,水题)相关推荐

  1. 洛谷 1563 玩具谜题——模拟水题

    题目:https://www.luogu.org/problemnew/show/P1563 模拟水题. #include<iostream> #include<cstdio> ...

  2. 【CCCC】L2-027 名人堂与代金券 (25分),模拟水题

    problem L2-027 名人堂与代金券 (25分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习"数据结构"课程的学生,想要获得一张合 ...

  3. poj 3095 Linear Pachinko 模拟水题

    题意: 给一个字符串,求小球随机放在上面进洞或到达两边之外的期望. 分析 水题,直接模拟. 代码: //poj 3095 //sep9 #include <iostream> using ...

  4. 【HDU - 1326】Box of Bricks(模拟水题)

    题干: Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds ...

  5. 一发模拟水题但是RE,暑假抽个时间改一改、、

    这是我们实验室纳新考试的A题,简单模拟. 话不多说上题干: 哲哲晔晔很难受 Description 哲哲和晔晔最喜欢一起睡懒觉了!可老师又特别喜欢点名,所以每个第一节有课的早晨,他们都会很难受. 因为 ...

  6. 数字罗列模拟水题-郑轻 2438

    原题传送 2438: shape of you 时间限制: 1 Sec  内存限制: 128 MB 提交: 279  解决: 234 [提交] [状态] [讨论版] [命题人:541607120135 ...

  7. [UVA12108]Extraordinarily Tired Students(模拟+水题)

    最近在填紫书上的坑(以前由于浮躁没有做的习题),发现还是有很多题比较麻烦,虽然思路很容易想,但就是写不出ac代码,可能这就是眼高手低吧.希望在接下来的学习生活中,从小事做起,向着自己的目标而努力吧. ...

  8. 牛客~~打篮球~~~模拟水题

    链接:https://www.nowcoder.com/acm/contest/118/D 来源:牛客网 题目描述 1, 2, 3在打篮球, 可是二打一总是不公平的, 于是他们决定一对一,另一个人在边 ...

  9. [ZOJ 4024] Peak

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4024 从前往后找满足al<al+1的最大下标l,从后往前找 ...

  10. 【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1889 题意:给出一个表,每个国家的石头剪子布的叫法,给两个人用自己国家的语言进行石头剪子布,进行统计,最 ...

最新文章

  1. android 美颜,「照骗」要消失了?Android 11 或禁用自动美颜
  2. 【Mac】安装 tesserocr 遇到的一些坑(‘cinttypes' file not found)
  3. HarmonyOS之常用组件Button的功能和使用
  4. web 应用开发最佳实践之一:避免大型、复杂的布局和布局抖动
  5. Git理论、原理、操作
  6. 还不知道 AWS 是什么?这 11 个重点带你认识 AWS !
  7. 程序员|那天下班回家,突然民警叫住我....
  8. c 与java性能测试_JNI只C性能测试
  9. DOM4j-中文API
  10. 从概率观点,怎样看新冠病毒的疫情
  11. 微软走进云南为网吧提供特价正版软件
  12. 编码规约学习——《阿里巴巴 Java 开发手册》
  13. 魔众在线题库管理系统v3.3.0源码
  14. Windows XP SP3 下 High Definition Audio 声卡安装方法
  15. ACM顽固错误之WA——常见掉坑点
  16. leetcode剑指offe刷题-第一题-用两个栈实现队列
  17. 满分作文生成器:生活在代码上
  18. python爬取网易云音乐飙升榜音乐_python爬取网易云音乐热歌榜实例代码
  19. manjaro下6.828实验环境配置
  20. 输入波长显示颜色 matlab,新手求助:由光谱反射率计算颜色的三刺激值

热门文章

  1. Microsoft SQL Server 2005数据库安装
  2. 自动化测试框架:没有Surprise的原因
  3. vue中waiting for update signal from wds_10个vue快捷开发技巧助你成为中级前端工程师!(二)...
  4. 1-1圆柱体的表面积(算法竞赛入门经典)
  5. java一维数组存入_java一维数组
  6. linux隐藏apache信息,Linux下如何隐藏Apache版本号信息
  7. pythonwhile输出每一个余数_Python 基础 - day02-3
  8. 大学只待成追忆,只是工作已半年,2016再见
  9. webpaper网页出题语言
  10. 秦九韶算法matlab程序,数值分析matlab程序实例.doc