PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBAHAI0000022. Đếm cực tiểu cục bộ (Count Local Minima)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm cực tiểu cục bộ (Count Local Minima)
Đếm cực tiểu cục bộ (Count Local Minima)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer sequence .
An element is a strict local minimum when and
The endpoints and are never considered local minima. If , the answer is .
Count the strict local minima.
Input
The first line contains integer . The second line contains space-separated integers .
Output
Print one integer: the number of strict local minima.
Subtasks
Subtask 1 (100 points): ; .
Example
Input
7
5 1 4 2 6 0 3
Output
3
Explanation
Positions contain respectively, each strictly smaller than both neighbors.