题目链接: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. java详细剖析

    1·类型加载主动初始化和被动初始化两种,通过访问静态变量或者给静态变量赋值都是可以使类初始化,如果有继承关系,所依赖的父类都会被动初始化. 2·如果在类的静态变量中添加final关键字,那这个变量就会 ...

  2. 创建docker公共仓库

    1.注册公共仓库的账号 https://hub.docker.com 账号:user-a 密码:pwd 2.Linux中登录docker公共仓库 docker login 3.上传一个docker镜像 ...

  3. webservice学习教程(三)--

    快速入门 首先,我们来尝试一下调用别人写好的webService 来体验一把:我们访问http://www.webxml.com.cn/zh_cn/index.aspx 进入到里边 当我们输入一个号码 ...

  4. 3.2.2 SpringMVC配置式开发

    SpringMVC配置式开发 1. SpringMVC运行原理(执行过程) 2. 需求 用户提交一个请求, 服务端处理器接收到请求后, 给出一条信息,在相应页面中显示该条信息 3. 开发步骤 (1) ...

  5. Linux进程PRI与NI值

    1.PRI -> 进程的优先级,大部分系统(Linux.UCOSII)都是数字越低优先级越高,进程就优先运行 , Linux中的PRI(new) = PRI(old) + nice ,其中 , ...

  6. PostgreSQL 9.5.x的架构图及外存图

  7. Oracle函数中对于NO_DATA_FOUND异常处理的研究

    一直以来有一个困惑,一直没解决,昨天一哥们问我这个问题,决心弄清楚,终于得到了答案.先看下面这个函数: create or replace function fn_test(c_xm varchar) ...

  8. Unity如何退出游戏

    使用 Application.Quit(),但在 editor 模式下使用 Application.Quit()是没用的,要用 EditorApplication.isPlaying = false. ...

  9. Python练习--普通函数与递归函数求阶乘

    '''Created on 2018年10月28日递归函数示例:阶乘'''def my_fun_example1(n):    '''    非递归函数求阶乘示例    '''    result = ...

  10. SV-assertion

    断言(assert)是一种描述性语言,通过描述的期望结果来进行仿真验证. 断言有一个更加基础的信息,我们称为属性(property),属性可以作为断言结果,功能覆盖点,形式检查和约束随机激励生成. 断 ...