Practice · 8 of 9
Mixed C1
CHALLENGE
Difficulty: advanced+25 XP
**Bài toán.** There are n points on a line (coordinate x[i]). Connecting two points costs |x[i] − x[j]|. Connect all points into one component at minimum total cost; print that cost. **Constraints:** 1 ≤ n ≤ 200000; 0 ≤ x[i] < 10^6. **Input:** line 1: n; line 2: n coordinates. **Output:** one integer.
Press Submit to check your solution.
Back to lesson: Practice: Mixed Sets A/B/C — Topics Hidden