Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Given an array of integers T, representing the heights of towers, print out the number of good towers.

A tower is good if it is strictly greater than the tower to the left of it and is strictly smaller than the tower to the right of it. Towers at the start and end of the array cannot be good.

Input Specification

You will receive two lines of input. The first will be integer N (1 \le N \le 10^6), representing the length of array T.

The next line will contain N space-separated integers.

It is guaranteed that each tower's height is in the range [-10^9, 10^9].

Output Specification

Output the number of good towers.

Sample Input 1

5
1 3 4 2 5

Sample Output 1

1

Comments


  • 0
    pto1026  commented on Nov. 6, 2021, 5:10 p.m.

    I have tried and tried and I can't figure out where I have gone wrong. It seems like a simple enough problem but 2 of the test cases keep failing and I don't know why.


    • 1
      Nils_Emmenegger  commented on Nov. 6, 2021, 7:31 p.m.

      Consider the test case

      3
      1 2 3