题目链接: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. SecureCRT连接linux步骤

    SecureCRT连接linux步骤  做个笔记,以免隔段时间后忘了 LINUX系统一般都是用来作服务器使用,而且都是通过命令行来操作,为了操作方便我们都会使用第三方软件来远程操作.CRT就是比较常用 ...

  2. MongoDB - Indexes

    #explain command pp db[:zips].find(:state => 'MD').explain #List all indexes: db[:zips].indexes.e ...

  3. thinkphp ckeditor与ckfinder

    thinkphp ckeditor与ckfinder 下载 ckeditor下载地址 ckfinder下载地址 整合 将ckeditor与findeditor下载完成后,放到public目录下,配置c ...

  4. 红黑树与AVL特性

    红黑树:比较平衡的二叉树,没有一条路径会比其他路径长2倍,因而是近似平衡的.所以相对于严格要求平衡的AVL树来说,它的旋转保持平衡次数较少.插入删除次数多的情况下我们就用红黑树来取代AVL. 红黑树规 ...

  5. 关于SQL配置管理工具无法打开0x8004100e问题!

    今天犯了个很“2”得问题,因为在远程数据库可以访问,并且也在安装程序中有看到装有SQLserver Mamngement Studio及其它程序,所以想在本地使用数据库应该可以但没想却总是报SQL配置 ...

  6. idea+maven下jrebel的安装破解

    链接地址:https://www.cnblogs.com/wang1024/p/7211194.html

  7. btcpool之Stratum协议

    一.简介 矿机(或挖矿软件)与矿池之间通过stratum协议通讯,它包括订阅.授权.下发难度.下发任务.提交share五种消息. 二.订阅(mining.subscribe) 矿机启动后,先和矿池建立 ...

  8. ESP8266 RTOS SDK编译环境搭建

    前提条件 1. linux操作系统或者windows下的linux虚拟机或者OS X操作系统 2. 联网 下载 * [Mac](https://dl.espressif.com/dl/xtensa-l ...

  9. 后台发送get请求

    第一步:编写Controller,让后台去请求接口 package controller; import java.util.List; import org.springframework.bean ...

  10. mysql----------原生的sql里面如何根据case then排序

    1.按照三个字段都符合条件来排序 ORDER BY (    CASE    WHEN is_top = 1    AND top_end_time>UNIX_TIMESTAMP()    AN ...