TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You’re given a sequence of integers (a1, a2, ..., aN). An element ai of the

sequence is called a local minimum if ai < ai-1 and ai < ai+1. A local maximum is
defined similarly. Obviously, the first and the last element of the sequence can’t be
neither a local minimum nor a local maximum.


Your task is to find the minimal value among the local maximums and the
maximal value among the local minimums in the given sequence.

Input Format

The first line of the
each testcase contains the integer N (1 ≤ N ≤ 1000000). It is followed by N integers whose
absolute values do not exceed 109, the elements of the sequence. The elements are
separated from each other by spaces and/or newlines.

Output Format

each testcase consisting of
exactly two lines. The first line should contain the minimal value among the local
maximums of the sequence, or the message ’No local maximums’
(without the quotes). The second line should contain the maximal value among the
local minimums of the sequence, or the message ’No local minimums’.

Sample Input 1

8
40
32
5
4
9
9
2
3

Sample Output 1

No local maximums
4

Hints

Problem Source

Migrated from old NTUJ.

icpc2008, neerc west

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200