Skip to main content

Checkpoint: The Label-Free Gauntlet

Challenge on lesson: Checkpoint — The Label-Free Gauntlet

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** A permutation p of 1..n is given. Count indices i such that p[i] is a "local maximum with distance d = min(i−1, n−i)": p[i] is greater than all elements within distance d on both sides. **Constraints:** 1 ≤ n ≤ 200000; p is a permutation of 1..n. **Input:** line 1: n; line 2: the permutation. **Output:** the count of such indices.

Back to lesson: Checkpoint — The Label-Free Gauntlet