Optimize Water Distribution in a Village

Implement solve for Optimize Water Distribution in a Village. Return the required output for the provided arguments.

Examples
Input: [3,[1,2,2],[[1,2,1],[2,3,1]]]
Output: 3
Hints

Optimize Water Distribution in a Village

Implement `solve` for **Optimize Water Distribution in a Village**. Return the required output for the provided arguments.