题目链接: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. python 循环 while

    count = 1while count <= 5: print("大家好!") count = count + 1 结果:while 可以进行循环, count 表示计数, ...

  2. Python环境——安装扩展库

    一.修改easy_install源 在操作用户家目录添加一个文件 cat >> ~/.pydistutils.cfg <<EOF [easy_install] index-ur ...

  3. NABCD分析---校园服务

    N(需求): 大学生活中,很多琐碎的小事浪费同学时间精力.我们的APP本着为同学服务的宗旨,解决生活中各方面的问题,同学们可以在APP上发布各种信息,例如兼职,二手买卖等等. A(做法): 用户打开A ...

  4. 在centos7 上安装Python3

    Centos7缺省是python2.7. 现在需要使Python2和python3 共存,所以需要单独安装python3. 但是需要注意的是如果按缺省方式安装,则会替换python为python3.x ...

  5. 面向对象:MATLAB的自定义类 [MATLAB]

    https://www.cnblogs.com/gentle-min-601/p/9785812.html 面向对象:MATLAB的自定义类 [MATLAB]   这几天刚刚开始学习MATLAB的面向 ...

  6. jquery datetimepicker 日期时间控件的使用及参数说明

    首先下载 jquery.datetimepicker.css jquery.datetimepicker.main.js 1. 引入css和js (注:该控件要依赖于jquery) <link ...

  7. Linux运维跳槽40道面试精华题

    Linux运维跳槽40道面试精华题 运维派 3天前 1.什么是运维?什么是游戏运维? 1)运维是指大型组织已经建立好的网络软硬件的维护,就是要保证业务的上线与运作的正常,在他运转的过程中,对他进行维护 ...

  8. PAT (Basic Level) Practice (中文)1001 害死人不偿命的(3n+1)猜想

    1001 害死人不偿命的(3n+1)猜想 卡拉兹(Callatz)猜想: 对任何一个正整数 n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把 (3n+1) 砍掉一半.这样一直反复砍下去,最后一 ...

  9. js选中变色,不选中鼠标放上变色

    <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8&quo ...

  10. textbox 未

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...