AT_abc468_a.Maximal Value

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer sequence of length NN: A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N).

Find the number of integers ii between 11 and N−2N-2 (inclusive) satisfying Ai<Ai+1>Ai+2A_i < A_{i+1} > A_{i+2}.

给你一个长度为 NN 的整数序列:A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N)。

求满足 Ai<Ai+1>Ai+2A_i < A_{i+1} > A_{i+2} 的整数 ii 的个数,其中 ii 的取值范围为 11 到 N−2N-2(含端点)。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 …\ldots ANA_N

输入从标准输入以如下格式给出:

NN
A1A_1 A2A_2 …\ldots ANA_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    6
    3 1 4 1 5 2

    输出#1

    2
  • 输入#2

    5
    1 1 1 2 1

    输出#2

    1
  • 输入#3

    10
    7 3 9 8 10 3 1 5 5 4

    输出#3

    2

说明/提示

Sample 1 Explanation:
Two values i=2,4i=2,4 satisfy the condition. Thus, output 22.

Constraints

  • 3≤N≤1003\le N\le 100
  • 1≤Ai≤1001\le A_i\le 100
  • All input values are integers.

样例 1 解释:
有两个值 i=2,4i=2,4 满足条件。因此,输出 22。

限制条件

  • 3≤N≤1003\le N\le 100
  • 1≤Ai≤1001\le A_i\le 100
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页