Skip to main content

Practice · 2 of 5

Tiered Max

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Read an array of n values and print the maximum. The catch: your program must be correct for every n — including n = 1 — and must not allocate more than a fixed 1000-cell array of work memory. Values may repeat. **Input:** Line 1: n (1 <= n <= 100000). Line 2: n integers (|a[i]| <= 10^9). **Output:** One integer — the maximum value. **Example:** 3 / -5 2 -9 -> 2.

Back to lesson: Practice: Contest Technique Problem Set