题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4024

从前往后找满足al<al+1的最大下标l,从后往前找满足ar−1>ar的最小下标r,如果l=r且1<l<n则满足条件

#include <iostream>
#include <cstdio> using namespace std; const int maxn = 100005; int arr[maxn]; int t, n; int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int l, r;
for (int i = 0; i < n - 1; i++) {
if (arr[i] >= arr[i + 1]) {
l = i;
break;
}
}
for (int i = n - 1; i >= l; i--) {
if (arr[i - 1] <= arr[i]) {
r = i;
break;
}
}
if (l == r && 0 < l && l < n - 1) {
printf("Yes\n");
} else {
printf("No\n");
}
}
}

[ZOJ 4024] Peak的更多相关文章

  1. The 15th Zhejiang Provincial Collegiate Programming Contest(部分题解)

    ZOJ 4024 Peak 题意 给出n和n个数,判断该数列是否是凸形的. 解题思路 从前往后第一对逆序数,和从后往前第一队逆序数,如果都非零而且相邻,证明该数组是凸形的. 代码 #include & ...

  2. C++版 - 剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题,ZOJ 1088:System Overload类似)题解

    剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题) 原书题目:0, 1, - , n-1 这n个数字排成一个圈圈,从数字0开始每次从圆圏里删除第m个数字.求出这个圈圈里剩下的最后一个数字 ...

  3. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  4. [LeetCode] Find Peak Element 求数组的局部峰值

    A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ ...

  5. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  6. LeetCode 162 Find Peak Element

    Problem: A peak element is an element that is greater than its neighbors. Given an input array where ...

  7. Find Peak Element

    A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ ...

  8. [LintCode] Find Peak Element 求数组的峰值

    There is an integer array which has the following features: The numbers in adjacent positions are di ...

  9. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

随机推荐

  1. 2019-04-25t16:19:49 转成正常的年月日

    1.首先得到的值时2019-04-25t16:19:49 2.想转成2019-04-25 3. var d = new Date(2019-04-25t16:19:49); var yy = d.ge ...

  2. 找出sql脚本中需要创建的表空间名称和数据库用户名

    测试的工作中,经常会遇到项目交接或者搭建一个新的测试环境,而创建oracle数据库用户及表空间时,需要提前找出脚本中的 数据库用户名和表空间名,所以自己写了一个python脚本,自动找出sql脚本中的 ...

  3. volatile有什么用?能否用一句话描述volatile的应用场景

    volatile保证内存可见性和禁止指令重排.volatile用于多线程环境下的单次操作(单次读或者单次写).volatile关键字不能提供原子性.     volatile关键字为实例域的同步访问提 ...

  4. 2019-04-27 Python之有关文件的学习

    一.文件 1.简介 二.文件的相关操作 1.打开文件 例如:  f = open("F:\\text.txt", 'r') 只读模式,不可写入 2.读取文件 例如: f.readl ...

  5. gitbook build/serve 失败,Error: ENOENT: no such file or directory, stat ...

    我使用的 gitbook 版本 CLI version: 2.3.2 GitBook version: 3.2.3 在使用 gitbook 生成文档时,发现编译偶尔不规律性地出现错误 d:\Mine\ ...

  6. msbuild 编译指定工程时构建脚本的配置

    有时候 ,我们编译windows的exe时,我们不需要编译所以的工程,我们只需要指定某个工程就好了,此时我们使用/t:工程名:Rebuild(如果要编译全部工程就把工程名去掉,即/t:Rebuild) ...

  7. eclipse myeclipse中的一些配置

    1.显示.setting 点击三角号 选择customsize view 取消.*resources myeclipse如何更改项目名 点击项目名->alt+enter(properties)

  8. 关于优先队列浅析(priority_queue)

    优先队列 greater与less,自定义还有结构体(可以设置2层优先级)  模板; 下面废话不多说直接上程序 注释的很明白 #include<iostream> #include< ...

  9. 3#Java案例

    以下内容引用Github地址https://github.com/DuGuQiuBai/Java/blob/master/day01/code/02_%E5%B8%A6%E6%B3%A8%E9%87% ...

  10. FB面经Prepare: Email User

    有一些账号,账号里面有一个或多个email, 如果两个账号有共同的email,则认为这两个账号是同一个人,找出哪些账号是同一个人 输入是这样的:数字是用户,字母是邮箱,有很多人有多个邮箱,找出相同的用 ...