OK, this one looked like mincost maxflow and binary search, but I am getting TLE. Binary search is needed to restrict flow on edges and to thus get more even distribution of flow, and costs are used to prefer Willy’s edges if possible. How did you guys solve it?