Minimum cost maximum flow https://www.luogu.org/problemnew/show/P3381 With negative edges, it will not work with normal dIjkstra.