N - Houses and Schools

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

Input

Output

Sample test(s)

Input
6 2 2 7 1 4 6 4
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
11
--- Showing first 30 lines (click "Copy" to get full content) ---

Notes