B - Garden of Giants

Languages: C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
3 2 1 1 3 3 2
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
5
--- Showing first 30 lines (click "Copy" to get full content) ---