#P1653. [USACO04DEC] Cow Ski Area G

[USACO04DEC] Cow Ski Area G

Output Format

Output the minimum number of lifts needed.

9 3
1 1 1 2 2 2 1 1 1
1 2 1 2 3 2 1 2 1
1 1 1 2 2 2 1 1 1
3

Hint

Constraints: 1W,L5001 \le W, L \le 500, 0H99990 \le H \le 9999.

Translated by ChatGPT 5