Peak


Time Limit: 1 Second      Memory Limit: 65536 KB

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
原题网站:
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5752 题意:给你一个数组让你求这个数组是不是一个山峰数组,就这个数组有先单调递增之后再单调递减两种情况 分别用flag1,flag2来标记是否有单调递增和单调递减情况,并且判断在递减情况是否有递增情况,但是要注意如果有相同的情况是不满足递增和递减要直接输出No(这里wa一次) 代码:
#include<bits/stdc++.h>
using namespace std; int a[];
int main()
{
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
for(int i=;i<n;i++){
cin>>a[i];
}
int flag=;
int flag1=,flag2=,flag4=;
int flag3=;
for(int i=;i<n;i++){
if(a[i]==a[i-]){//判断是否有相同的值的情况
flag4=;
}
if(!flag){//标记是否有单调递增
if(a[i]>a[i-]){
flag1=;
}
if(a[i]<a[i-]){//标记是否单调递减
flag=;
flag2=;
}
}
else{//标记是否在单调递减的时候还有单调递增的情况
if(a[i]>a[i-]){
flag3=;
break;
}
}
}
if(flag3==||(flag1+flag2!=)||flag4==)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
return ;
}


The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple -A Peak的更多相关文章

  1. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

  2. 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...

  3. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7

    Lucky 7 Time Limit: 1 Second      Memory Limit: 65536 KB BaoBao has just found a positive integer se ...

  4. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?

    CONTINUE...? Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge DreamGrid has  clas ...

  5. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - B King of Karaoke

    King of Karaoke Time Limit: 1 Second      Memory Limit: 65536 KB It's Karaoke time! DreamGrid is per ...

  6. ZOJ 4033 CONTINUE...?(The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple)

    #include <iostream> #include <algorithm> using namespace std; ; int a[maxn]; int main(){ ...

  7. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - F 贪心+二分

    Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = { ...

  8. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - C 暴力 STL

    What Kind of Friends Are You? Time Limit: 1 Second      Memory Limit: 65536 KB Japari Park is a larg ...

  9. ZOJ 3962 E.Seven Segment Display / The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple E.数位dp

    Seven Segment Display Time Limit: 1 Second      Memory Limit: 65536 KB A seven segment display, or s ...

随机推荐

  1. java高精度类尝试

    java高精度尝试, poj2109,比较坑的题目 import java.io.*; import java.util.*; import java.math.*; public class Mai ...

  2. chrome 不支持12px以下字体为题的解决

    现英文9px 设置 在chrome 下无效,可以通过 -webkit-transform: scale(0.75); 12*0.75 =9  得到小字体(在chrome浏览器下 大小缩放到0.75倍) ...

  3. 闲话JavaScript与Cookies

    使用 Cookies 我们已经知道,在 document 对象中有一个 cookie 属性.但是 Cookie 又是什么?"某些 Web 站点在您的硬盘上用很小的文本文件存储了一些信息,这些 ...

  4. vsftpd主动模式和被动模式的区别

    何为主动模式,何为被动模式 1.ftp采用两个端口控制: 20端口用于数据传输. 21端口用于控制,或指建立TCP连接. 2.主动方式连接过程: [注意]:C表示客户端 S表示服务器端 S端要开启20 ...

  5. 初识 spl_autoload_register

    spl_autoload_register 一.首先我们看来自官网的定义 版本要求:php版本为5.1.2+ 说明:注册给定的函数作为__autoload的实现.即自动加载 函数参数说明: bool ...

  6. io缓冲为何可以提高效率

    问题 据我了解,运用FileInputStream读写一段数据是一个字节一个字节的读取,如果有10个字节大小的文件,就要调用10次系统调用,每次将读取的数据赋值给变量,然后程序使用变量. 缓冲区可以看 ...

  7. import as from import 区别

    在python中import或者from…import是用来导入相应的模块.那每一种有什么具体的差别呢? 一.import        只有import,为最简单的引入对应的包.例如: import ...

  8. 基于MapReduce的手机流量统计分析

    1,代码 package mr; import java.io.IOException; import org.apache.commons.lang.StringUtils; import org. ...

  9. idea 将工程项目打包成war

    1.File--Project structure ---- Artifacts ----- + -----web Application :Archive ---for ' **:war explo ...

  10. PCIe 调试

    ISE 生成PCIe核之后, 在ipcore_dir目录下会产生以下文件目录 目录下包含内容如下: The doc folder contains the PCIe Endpoint Block da ...